Skip to content
Onycx-ui
ESC

Fit Word

Fit a display word to a chosen share of its container using the width of the loaded font.

Dependencies
No extra packages
Size
104 lines
Controls
8 controls

Installation

CLI · shadcn registry

npx shadcn@latest add https://ui.onycx.dev/r/fit-word.json

1 · Dependencies

None beyond React and Tailwind.

2 · Copy the source

components/onycx/fit-word.tsx

Requires React 19 and Tailwind CSS v4. Copy the source from the fit-word.tsx tab after tweaking: your values are baked in as the new defaults. Exported image examples use portable sample artwork. Replace it with your own media as needed.

Props

PropTypeDefaultDescription
wordstring"STRAWBERRY"The word to fit. Keep it to one line.
fillnumber0.9Share of the container width the word occupies.
maxRationumber0.25Font-size ceiling as a share of the width, so short words stay in proportion.
weightnumber800Font weight; the measurement reads the element's computed weight.
trackingnumber-0.075Letter-spacing in em. As in the original it is not measured, so negative tracking lands slightly inside the fill.
lineHeightnumber0.88Line-height of the word.
colorstring"#4d192b"Fill, or stroke colour when outlined.
outlinebooleanfalseHollow letters with a max(1px, 0.012em) text stroke.
align"left" | "center" | "right""center"Where the word sits inside the frame.
decorativebooleantruearia-hidden, as in the original where the word repeats the product name; set false when it is the only label.