Files
WRNexusJSDoc/app/pages/components/button-group.wrn
T

118 lines
8.3 KiB
Plaintext

page ButtonGroupcomponent {
seo {
title = "ButtonGroup component"
description = "Theme-aware, responsive button group component."
}
view {
<div class="docs-shell">
<SkipLink label="Skip to content" href="#main" class="docs-skip-link" />
<header class="topbar">
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.5.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
</header>
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
<main class="portal-main docs-layout component-detail-page"><article id="main" class="documentation prose standalone"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/components">Components</a><span>/</span><span aria-current="page">ButtonGroup</span></nav><section class="doc-intro"><span class="eyebrow">base component</span><h1>ButtonGroup</h1><p>Theme-aware, responsive button group component.</p><div class="doc-meta"><span>@wrnexus/ui 0.5.0</span><span>13 props</span><span>1 slots</span><span>3 events</span></div></section><section id="usage"><h2>Usage</h2><p>Components are auto-discovered. Use the component directly in any <code>.wrn</code> view:</p><pre data-language="wrn"><code>&lt;ButtonGroup
items=&quot;[]&quot;
value=&quot;value&quot;
size=&quot;md&quot;
color=&quot;primary&quot;
variant=&quot;default&quot;
/&gt;</code></pre><p>Legacy mount name: <code>data-component=&quot;ButtonGroup&quot;</code>.</p></section><section id="props"><h2>Props and attributes</h2><div class="table-wrap"><table><thead><tr><th>Prop</th><th>Type</th><th>Requirement</th><th>Default</th></tr></thead><tbody><tr><td><code>items</code></td><td><code>string</code></td><td>Optional</td><td><code>[]</code></td></tr><tr><td><code>value</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>size</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;md&quot;</code></td></tr><tr><td><code>color</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;primary&quot;</code></td></tr><tr><td><code>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;default&quot;</code></td></tr><tr><td><code>orientation</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;horizontal&quot;</code></td></tr><tr><td><code>responsive</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>attached</code></td><td><code>boolean</code></td><td>Optional</td><td><code>true</code></td></tr><tr><td><code>selectable</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>toolbar</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>disabled</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>ariaLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Button group&quot;</code></td></tr><tr><td><code>class</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr></tbody></table></div></section><section id="slots"><h2>Slots</h2><ul><li><code>default</code></li></ul></section><section id="events"><h2>Events</h2><ul><li><code>click</code></li><li><code>select</code></li><li><code>change</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/ButtonGroup.wrn</code></p><pre data-language="wrn"><code>component ButtonGroup &#123;
props &#123;
@event click = function
@event select = function
@event change = function
items = []
value = &quot;&quot;
size = &quot;md&quot;
color = &quot;primary&quot;
variant = &quot;default&quot;
orientation = &quot;horizontal&quot;
responsive = false
attached = true
selectable = false
toolbar = false
disabled = false
ariaLabel = &quot;Button group&quot;
class = &quot;&quot;
&#125;
state selectedValue = value
functions &#123;
function itemValue(item, index) &#123;
return item.value || item.label || String(index)
&#125;
function selectItem(item, index) &#123;
previousValue = selectedValue
nextValue = itemValue(item, index)
$emit(&quot;select&quot;, &#123;
value: nextValue,
previousValue: previousValue,
item: item,
index: index
&#125;)
if (selectable &amp;&amp; previousValue !== nextValue) &#123;
selectedValue = nextValue
$emit(&quot;change&quot;, &#123;
value: nextValue,
previousValue: previousValue,
item: item,
index: index
&#125;)
&#125;
&#125;
&#125;
view &#123;
&lt;div
&#123;...attrs&#125;
class=&quot;wire-next wire-next--button-group &#123;class&#125;&quot;
role=&quot;&#123;toolbar ? 'toolbar' : 'group'&#125;&quot;
aria-label=&quot;&#123;ariaLabel&#125;&quot;
aria-orientation=&quot;&#123;orientation&#125;&quot;
data-size=&quot;&#123;size&#125;&quot;
data-color=&quot;&#123;color&#125;&quot;
data-variant=&quot;&#123;variant&#125;&quot;
data-orientation=&quot;&#123;orientation&#125;&quot;
data-responsive=&quot;&#123;responsive&#125;&quot;
data-attached=&quot;&#123;attached&#125;&quot;
data-selectable=&quot;&#123;selectable&#125;&quot;
data-disabled=&quot;&#123;disabled&#125;&quot;
&gt;
&#123;#if items&#125;
&#123;#each items as item, index&#125;
&lt;button
type=&quot;&#123;item.type || 'button'&#125;&quot;
class=&quot;wire-btn wire-btn--variant-&#123;item.variant || variant&#125; wire-btn--color-&#123;item.color || color&#125; wire-btn--size-&#123;item.size || size&#125;&quot;
disabled=&quot;&#123;disabled || item.disabled&#125;&quot;
aria-label=&quot;&#123;item.ariaLabel || item.label&#125;&quot;
aria-pressed=&quot;&#123;selectable ? (selectedValue === (item.value || item.label || String(index)) ? 'true' : 'false') : ''&#125;&quot;
data-value=&quot;&#123;item.value || item.label || String(index)&#125;&quot;
data-selected=&quot;&#123;selectable &amp;&amp; selectedValue === (item.value || item.label || String(index)) ? 'true' : 'false'&#125;&quot;
@click=&quot;selectItem(item, index)&quot;
&gt;
&#123;#if item.icon&#125;
&lt;span class=&quot;wire-btn__icon &#123;item.icon&#125;&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&#123;/if&#125;
&lt;span class=&quot;wire-btn__label&quot;&gt;&#123;item.label&#125;&lt;/span&gt;
&lt;/button&gt;
&#123;/each&#125;
&#123;/if&#125;
&lt;slot /&gt;
&lt;/div&gt;
&#125;
&#125;
</code></pre></section></article><aside class="on-this-page"><h2>On this page</h2><nav><a href="#usage">Usage</a><a href="#props">Props and attributes</a><a href="#slots">Slots</a><a href="#events">Events</a><a href="#source">Source contract</a></nav></aside></main>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.5.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
<BackToTop />
</div>
}
}