Developers
Start building
Themes/Theme SDK/Modules/ui

ui

Generic interface primitives, class merging and DOM hooks.

On this page
import { … } from '@poltura/theme-sdk/ui';

Hooks

NameWhat it is
useMediaQueryWhether the browser's viewport matches a media query; false on the server and while hydrating.
useInViewA reveal-on-scroll flag for an entrance animation; it starts true so content never stays hidden.
useSnapCarouselDrives a CSS scroll-snap track: autoplay, the active slide and the controls behind dots or thumbnails.
useRovingTabsArrow, Home and End key handling for a tablist whose selected tab alone is in the tab order.

Parts

NameWhat it is
ButtonA button in the store's primary, secondary, outline, ghost, link or destructive look.
BadgeA small label for a status, count or tag.
CardA bordered surface that groups related content.
CardHeaderThe top part of a Card, holding its title and description.
CardTitleThe heading of a Card.
CardDescriptionThe muted supporting line under a CardTitle.
CardContentThe main body of a Card.
CardFooterThe bottom row of a Card, for actions.
InputA single-line text field.
LabelThe visible name of a form field, tied to it with htmlFor.
TextareaA multi-line text field.
CheckboxA checkbox in the store's colours, tied to its Label with id and htmlFor.
SelectA dropdown that picks one value from a list; compose it with its trigger, value and items.
SelectTriggerThe button of a Select that shows the chosen value and opens the list.
SelectValueThe chosen item's text, or a placeholder, inside a SelectTrigger.
SelectContentThe popover list of a Select, holding its items.
SelectItemOne choice inside a SelectContent.
DialogA modal dialog: focus stays inside while it is open, and Escape or a click outside closes it.
DialogContentThe dialog's panel, centred over a dimmed page.
DialogHeaderThe top of a dialog, holding its title and description.
DialogFooterThe bottom of a dialog, holding its buttons; they stack on phones.
DialogTitleThe dialog's title; screen readers announce it when the dialog opens.
DialogDescriptionThe line under a dialog's title; screen readers read it with the title.
DropdownMenuA menu that drops from a button: arrow keys walk its items, typing jumps to one, and Escape or a click outside closes it.
DropdownMenuTriggerThe button that opens a DropdownMenu; it carries data-state="open" while the menu is open.
DropdownMenuContentThe menu's panel, drawn over the page under its button and kept inside the window.
DropdownMenuItemOne item of a DropdownMenu; with asChild a link becomes the item itself.
SheetA drawer that slides in from an edge of the window, such as a mobile menu or a filter panel.
SheetContentThe drawer's panel over a dimmed page, full height on the left and right edges.
SheetHeaderThe top of a drawer, holding its title.
SheetTitleThe drawer's title; screen readers announce it when the drawer opens.
PopoverA panel that opens from a button over the page without dimming it; Escape or a click outside closes it.
PopoverTriggerThe button that opens a Popover; it carries data-state="open" while the popover is open.
PopoverContentThe popover's panel, drawn over the page next to its button and kept inside the window.
SeparatorA thin line that divides content.
SkeletonA pulsing placeholder block shown while content loads.
CarouselA swipeable, keyboard-friendly slider; compose it with its content, items and arrows.
CarouselContentThe track inside a Carousel that holds its slides.
CarouselItemOne slide of a Carousel; add a width class such as basis-1/3 to show several at once.
CarouselPreviousThe arrow that moves a Carousel back one step.
CarouselNextThe arrow that moves a Carousel forward one step.
InlineErrorA field's error message, announced to screen readers and drawn only when there is one.
IconDraws an icon setting's value as inline SVG in the current text colour.
TooltipA hover and focus tooltip that renders only its child on the server, so it never breaks hydration.
PageLinksLinks to the neighbouring and the first and last pages of a paged list.

Functions

NameWhat it is
cnJoins class names, skips falsy ones and resolves conflicting Tailwind classes so the last one wins.

Types

NameWhat it is
ButtonPropsProps of Button.
BadgePropsProps of Badge.
CardPropsProps of Card.
CardHeaderPropsProps of CardHeader.
CardTitlePropsProps of CardTitle.
CardDescriptionPropsProps of CardDescription.
CardContentPropsProps of CardContent.
CardFooterPropsProps of CardFooter.
InputPropsProps of Input.
LabelPropsProps of Label.
TextareaPropsProps of Textarea.
CheckboxPropsProps of Checkbox.
SelectPropsProps of Select.
SelectTriggerPropsProps of SelectTrigger.
SelectValuePropsProps of SelectValue.
SelectContentPropsProps of SelectContent.
SelectItemPropsProps of SelectItem.
DialogPropsProps of Dialog.
DialogContentPropsProps of DialogContent.
DialogHeaderPropsProps of DialogHeader.
DialogFooterPropsProps of DialogFooter.
DialogTitlePropsProps of DialogTitle.
DialogDescriptionPropsProps of DialogDescription.
DropdownMenuPropsProps of DropdownMenu.
DropdownMenuTriggerPropsProps of DropdownMenuTrigger.
DropdownMenuContentPropsProps of DropdownMenuContent.
DropdownMenuItemPropsProps of DropdownMenuItem.
SheetPropsProps of Sheet.
SheetContentPropsProps of SheetContent.
SheetHeaderPropsProps of SheetHeader.
SheetTitlePropsProps of SheetTitle.
PopoverPropsProps of Popover.
PopoverTriggerPropsProps of PopoverTrigger.
PopoverContentPropsProps of PopoverContent.
SeparatorPropsProps of Separator.
SkeletonPropsProps of Skeleton.
CarouselOptionsThe options a Carousel accepts.
CarouselApiThe carousel's controller, for reading which slide shows and moving between slides.
CarouselPropsProps of Carousel.
CarouselContentPropsProps of CarouselContent.
CarouselItemPropsProps of CarouselItem.
CarouselPreviousPropsProps of CarouselPrevious.
CarouselNextPropsProps of CarouselNext.
InlineErrorPropsProps of InlineError.
IconPropsProps of Icon.
TooltipPropsProps of Tooltip.
PageLinksPropsProps of PageLinks.
ClassFlagA flag in an object of flags: its class name applies while the flag is truthy.
ClassValueAnything cn turns into class names: strings, numbers, nested arrays and objects of flags.
InViewOptionsOptions of useInView.
InViewWhat useInView returns.
SnapCarouselOptionsOptions of useSnapCarousel.
SnapCarouselWhat useSnapCarousel returns.
RovingTabOne tab of a tablist that useRovingTabs moves focus between.
RovingTabsOptionsOptions of useRovingTabs.
Last updated