Toggle
Toggle
<div class="flex flex-wrap gap-2">
<button type="button" class="toggle" aria-pressed="false">Bold</button>
<button type="button" class="toggle" aria-pressed="true">Italic</button>
<button type="button" class="toggle" aria-pressed="false">Underline</button>
</div> Usage
Include CSS
@import "tailwindcss";
@import "5h3ll-ui/vega.css";Or import only the base CSS, Toggle component CSS, and one style pack.
@import "tailwindcss";
@import "5h3ll-ui/base.css";
@import "5h3ll-ui/components/toggle.css";
@import "5h3ll-ui/styles/vega.css"; Add your toggle HTML
5h3ll-ui Toggle is a native <button> that uses aria-pressed for state. This intentionally maps the upstream concept onto the platform instead of introducing a custom primitive.
<button type="button" class="toggle" aria-pressed="false">Bold</button> HTML structure
<button type=“button” class=“toggle” aria-pressed=“false|true”>- The toggle button. Update
aria-pressedwhen your app changes state. data-variant=“default|outline”Optional- Visual variant. Omit
data-variantfor the filled default style. data-size=“default|sm|lg|icon|icon-sm|icon-lg”Optional- Size variant aligned with the Button sizing model.
Examples
Outline
<div class="flex flex-wrap gap-2">
<button type="button" class="toggle" data-variant="outline" aria-pressed="true">Preview</button>
<button type="button" class="toggle" data-variant="outline" aria-pressed="false">Code</button>
</div> Icon
<div class="flex flex-wrap gap-2">
<button type="button" class="toggle" data-size="icon" aria-pressed="false" aria-label="Bold"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4h8a4 4 0 0 1 0 8H6z" /><path d="M6 12h9a4 4 0 0 1 0 8H6z" /></svg></button>
<button type="button" class="toggle" data-size="icon" aria-pressed="true" aria-label="Italic"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" /></svg></button>
<button type="button" class="toggle" data-size="icon" aria-pressed="false" aria-label="Underline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" /></svg></button>
</div> Disabled
<div class="flex flex-wrap gap-2">
<button type="button" class="toggle" disabled aria-pressed="false">Disabled</button>
<button type="button" class="toggle" data-variant="outline" disabled aria-pressed="true">Pressed</button>
</div>