6.5 daisyUI 便利コンポーネント
これらのヘルパーは frontend から再エクスポートされ、frontend/daisyui
からも利用できます。多くは daisyUI の標準的なマークアップへ直接対応し、
Node の子要素を受け取ります。
タイポグラフィ・ボタン
TextNode(text string) Nodespanでテキストを描画。
PrimaryButton(label string, props ComponentProps) NodeSecondaryButton(label string, props ComponentProps) NodeGhostButton(label string, props ComponentProps) NodeButtonにbtn-primary/btn-secondary/btn-ghostを付与するショートカット。
ButtonWithVariants(label, variant, size, style string, props ComponentProps) Node- 空でない値に対して
btn-<variant>/btn-<size>/btn-<style>を追加。
- 空でない値に対して
ナビゲーション・メニュー・レイアウト
Navbar(start, center, end Node) Nodenavbar-start/navbar-center/navbar-endのスロットを出力。
Menu(items ...Node) Nodeliではない項目をliでラップ。
Footer(children ...Node) NodeDrawer(id string, side, content Node) Nodeidを drawer toggle input と overlay label の紐付けに使用。
Dropdown(trigger, menu Node) NodeDropdownWithPlacement(trigger, menu Node, placement string) Nodeplacementが空でない場合dropdown-<placement>を追加。
Join(children ...Node) NodeJoinWithDirection(direction string, children ...Node) Nodedirectionが空でない場合join-<direction>を追加。
Hero・Avatar・Mockup
Hero(title, description string, actions ...Node) NodeAvatar(src, alt, class string) Node- 指定した wrapper class の中に
imgを置く daisyUI avatar マークアップ。
- 指定した wrapper class の中に
Stat(title, value, desc string) NodeBrowserMockup(content Node) NodePhoneMockup(content Node) NodeMockupWindow(title string, content Node) Nodetitleは API の対称性のため受け取りますが、現時点では描画されません。
CodeMockup(lines ...string) Node- 各行を
data-prefix="$"付きの mock terminal 行として描画。
- 各行を
開閉・ステップ・タイムライン・タブ・カルーセル
Accordion(title string, content Node, open bool) Nodename="accordion"の radio ベース collapse。
Collapse(title string, content Node, open bool) Node- checkbox ベース collapse。
Steps(items ...Node) NodeStep(label string, active bool) Nodeactiveでstep-primaryを追加。
StepsWithVariants(items []Node, direction, color, className string) Nodesteps-<direction>とclassNameを追加。color指定時は既存のstep子要素へstep-<color>を付与。
Timeline(items ...Node) NodeTimelineItem(startLabel, endLabel string, content Node) NodeTimelineWithDirection(items []Node, direction string, compact bool, snapIcon bool, className string) Nodetimeline-<direction>/timeline-compact/timeline-snap-icon/classNameを条件付きで追加。
TabsWithVariants(items []TabsItem, style, placement, size, className string) Nodetabs-<style>/tabs-<placement>/tabs-<size>/classNameを追加。TabsItem.Activeはtab-activeとaria-selected="true"を設定。TabsItem.Disabledはtab-disabledとdisabledを設定。
Carousel(items ...Node) NodeCarouselItem(id string, child Node) Node
入力・フォーム補助
Range(name string, value int, min int, max int) NodeRangeWithVariants(name string, value int, min int, max int, color, size string) Noderange-<color>/range-<size>を追加。
Rating(name string, max int, checked int) NodeRatingWithVariants(name string, max int, checked int, size string, half bool, allowClear bool) Noderating-<size>とrating-halfを条件付きで追加。allowClearで値0の hidden radio を先頭に追加。
Toggle(name string, checked bool) NodeToggleVariant(name string, checked bool, variant string) Nodeprimary,secondary,accent,neutral,info,success,warning,danger/errorを認識。
ToggleWithVariants(name string, checked bool, color string, size string) Nodetoggle-<color>/toggle-<size>を追加。
ToggleWithIcons(name string, checked bool, className string) NodeThemeController(options ...Node) NodeThemeControllerOption(theme string, checked bool, className string) Nodetheme-controller付き、name="theme-buttons"の radio input を出力。
Fieldset(legend string, fields ...Node) NodeLabel(text string) NodeValidator(message string) Node
フィードバック・オーバーレイ・視覚効果
Tooltip(text string, child Node) NodeTooltipWithVariants(text string, child Node, placement, color string, open bool) Nodetooltip-<placement>/tooltip-<color>/tooltip-openを追加。
ToastWithPlacement(children []Node, horizontal, vertical, className string) Nodetoast-<horizontal>/toast-<vertical>/classNameを追加。
Loading(sizeClass string) Node- 既定は
loading loading-spinner。sizeClassが空でなければ追加。
- 既定は
LoadingWithVariants(kind string, size string) Nodekind空文字はspinner。size指定時はloading-<size>を追加。
RadialProgress(value int, sizeClass string) NodeStatus(colorClass string) NodeStatusWithVariants(color string, size string) Nodestatus-<color>/status-<size>を追加。
Swap(onNode, offNode Node, active bool) NodeSwapWithVariants(onNode, offNode Node, active bool, rotate bool, flip bool) Node- flag に応じて
swap-active/swap-rotate/swap-flipを追加。
- flag に応じて
FAB(icon Node, label string) Nodelabelは button のaria-labelとして使用。
SpeedDial(trigger Node, items ...Node) Node
データ表示・メディア・ユーティリティ
List(items ...Node) Nodeliでない項目をラップし、list entry にlist-rowを追加。
Table(headers []string, rows ...[]Node) NodeTableWithVariants(headers []string, rows [][]Node, zebra bool, pinRows bool, pinCols bool, size string) Nodetable-zebra/table-pin-rows/table-pin-cols/table-<size>を条件付きで追加。
Kbd(text string) NodeCode(text string) NodeIndicator(item, target Node) NodeMask(shapeClass string, child Node) NodeChatBubble(content Node, end bool) Nodeendでchat-startからchat-endに切り替え。
Countdown(value int) NodeDock(items ...Node) NodeDockItem(child Node, active bool) Nodeactiveでdock-activeを追加。
Filter(items ...Node) NodeFilterItem(label string, active bool) Nodearia-labelにlabelを設定した radio input。
Calendar(content Node) NodeCalendarGrid(days ...Node) NodeDiff(before, after Node) NodeTextRotate(words []string, animationClass string) NodeHover3DCard(content Node) NodeHoverGallery(items ...Node) Node