Icon

An SVG icon from the icon sprite, picked by a typed name.

React, Vue, Solid, Svelte, Preact, and Lit

An svg that points at one icon in the sprite with <use>, styled with the icon recipe. name only accepts icons that exist, and the icon takes the text color. In Lit and plain HTML it's the <ib-icon> element.

Usage

import { Icon } from "@isbatak/react-ui/icon"
import { HStack } from "styled-system/jsx"

export function IconDemo() {
  return (
    <HStack gap="4">
      <Icon name="home" size="lg" />
      <Icon name="search" size="lg" />
      <Icon name="bell" size="lg" />
      <Icon name="settings" size="lg" />
    </HStack>
  )
}

Sizes

size sets a fixed box from the spacing scale, from xs to 2xl.

Font size

Leave size out and the icon is 1em, so it scales with the text around it.

Small text Body text Large text

Color

An icon takes the text color, so it matches the label next to it.

SavedFailedAsk AI

Props

PropDefaultDescription
nameThe icon to show. Only built-in names type-check, or your own once you replace the set
sizeinheritinherit sizes the icon to 1em. xs, sm, md, lg, xl and 2xl set a fixed box

Other SVG attributes pass through to the svg, and in React, Solid and Vue so do Panda style props like color. Icons render with aria-hidden, so put the accessible name on the button or link around them. <ib-icon> takes name and size as attributes.