Icon
An SVG wrapper. It sets the viewBox, sizing, and stroke defaults so icon paths can be dropped in as children.
import { Icon } from "antlitz";
API
| Prop | Type | Default |
|---|---|---|
| as | ElementType | svg |
| size | string | number | 24 |
| variant | "stroke" | "fill" | "plain" | stroke |
size is a number in pixels rather than a variant name, because icons are
sized to the text beside them rather than to a scale.
as renders a different component while keeping Icon's props — how an icon
from a library like lucide-react inherits the system's sizing and stroke
treatment.
Variants
export function Variants() {
return (
<>
<Icon size={24}>
<path d="M12 5v14M5 12h14" />
</Icon>
<Icon size={24} variant="fill">
<circle cx="12" cy="12" r="9" />
</Icon>
<Icon size={24} variant="plain">
<circle cx="12" cy="12" r="9" fill="currentColor" opacity="0.2" />
<path d="M12 8v8" stroke="currentColor" strokeWidth="2" />
</Icon>
</>
);
}stroke sets fill-none stroke-current with a 2px round-capped stroke, fill
sets fill-current stroke-none, and plain leaves both alone for
multi-colour artwork.
Sizes
export function Sizes() {
return (
<>
<Icon size={16}>
<path d="M12 5v14M5 12h14" />
</Icon>
<Icon size={24}>
<path d="M12 5v14M5 12h14" />
</Icon>
<Icon size={32}>
<path d="M12 5v14M5 12h14" />
</Icon>
</>
);
}Children are raw SVG elements — path, circle, rect — drawn on a 24×24
viewBox. antlitz ships no icon set; use any library's paths, or your own.
Accessibility
export function Accessibility() {
return (
<>
<Button variant="outline" size="icon" aria-label="Add item">
<Icon size={16}>
<path d="M12 5v14M5 12h14" />
</Icon>
</Button>
<Button variant="outline">
<Icon size={16}>
<path d="M12 5v14M5 12h14" />
</Icon>
Add item
</Button>
<Icon size={20} aria-label="Information">
<circle cx="12" cy="12" r="9" />
<path d="M12 8v4M12 16h.01" />
</Icon>
</>
);
}An Icon is aria-hidden unless given an aria-label, so decorative icons
beside text are skipped rather than announced twice. Label it only when the
icon is the sole content of a control.