Labelling Nubo icons for screen readers.
Most icons sit next to text that already says what they mean, so Nubo hides them from screen readers by default: every icon renders with aria-hidden="true".
Next to a visible label, do nothing. The label is what gets read.
<button>
<TrashIcon />
Delete
</button>When the icon is the only thing in a control, label the control, not the icon:
<button aria-label="Delete">
<TrashIcon />
</button>The button is what gets focused and announced, so that's where the name belongs.
When an icon stands on its own and says something, such as a status in a table, give it a title or an aria-label. The icon then renders with role="img" and is announced.
<CircleCheckIcon title="Verified" />Icons that point a direction, such as arrows, chevrons, undo and sign-out, should be mirrored in right-to-left layouts. Icons like clocks, checkmarks and media controls stay as they are.
In React, every icon that should mirror has the class nubo-mirror. Add one rule to your CSS and they all flip wherever the text runs right to left:
.nubo-mirror:dir(rtl) {
scale: -1 1;
}To override an icon, pass mirrored. mirrored={false} keeps it as drawn in every direction, for an arrow that means a fixed side of the screen. mirrored on its own always flips it.
MorphIcon needs no CSS: it reads the text direction itself and morphs to the mirrored icon, so arrow-right points left.
With plain SVG, icons.json in @nubo-icons/svg marks each icon's rtl as mirror or none.