Documentation

Slot

Slot merges its props and classes into its only child — the engine of asChild — and VisuallyHidden names things for screen readers only.

WebStableFoundations

Web only — React, from @krizaka/ui/slot. Stable: its API only changes in a major version.

When to use

  • To give your own component an asChild prop.
  • VisuallyHidden for words that only assistive technology needs: an icon button's name, a table caption.

When not to use

  • To style a link like a button: asChild on the button does it.Use instead: Button
  • To hide something from everyone: use hidden.

Installation

Install

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { Slot, VisuallyHidden } from "@krizaka/ui/slot";

Examples

Slot

The link is rendered, styled by the Slot.

VisuallyHidden

An icon button named for screen readers.

Props

This module has no component props: see the import and the preview above.

Accessibility

  • VisuallyHidden is read by screen readers and not shown.
  • Slot keeps the child's element: a link stays a link, with its role and keyboard.

Best practices

  • Slot takes exactly one child element.
  • Prefer a visible label to VisuallyHidden when there is room for one.

Generated from the code of @krizaka/ui 2.0.0-beta.6: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page