radix-ui / themes

Radix Themes is an open-source component library optimized for fast development, easy maintenance, and accessibility. Maintained by @workos.

Home Page:https://radix-ui.com/themes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Left align Radio Card

penx opened this issue · comments

In the first example for the Checkbox Card and Radio Card in the docs, the text is left aligned because it has a Flex child that sets this.

Screenshot 2024-05-02 at 15 37 05

https://www.radix-ui.com/themes/docs/components/checkbox-cards

Screenshot 2024-05-02 at 15 37 48

https://www.radix-ui.com/themes/docs/components/radio-cards

By default the alignment of contents within a checkbox/radio card is centered.

If the intention is to support left alignment of text in a checkbox/radio card item, could it be given a prop to set this, rather than requiring nesting a Flex within it?

If the intention is to discourage left alignment, could the example at the top of the docs be changed to something centre aligned? 😄

The alignment choice is by design:

  • The checkbox card is left aligned by default because of the checkbox on the right.
  • The radio card was made center aligned by default because it's the most vanilla / good-looking option out of the box for simple one-liners.
    • That Flex example in the docs should probably be moved to the Examples section, and the base example should be simpler.
    • Using composition to achieve a different layout is encouraged. Not sure how we'd feel about a layout prop there as some common layouts are just too different and can't be covered with props reasonably well compared to composition (namely: a single center-aligned line of text (works out of the box), text + icon horizontally (works out of the box), 2+ lines of text left-aligned (needs composition)).