Documentation
¶
Index ¶
- Constants
- Variables
- func Blockquote(args ...any) *blockquote
- func Button(args ...any) *button
- func ButtonGroup(args ...any) *buttonGroup
- func Checkbox(args ...any) *checkbox
- func CheckboxGroup(helperText string, args ...any) *checkboxGroup
- func ClassForTheme(a Attr) string
- func CloseButton(args ...any) *button
- func Code(args ...any) *codeSnippet
- func CodeBlock(args ...any) *codeSnippet
- func CodeSnippet(args ...any) *codeSnippet
- func Col(n int, args ...any) *grid
- func Col1(args ...any) *grid
- func Col2(args ...any) *grid
- func Col4(args ...any) *grid
- func Col6(args ...any) *grid
- func Col8(args ...any) *grid
- func Col10(args ...any) *grid
- func Col12(args ...any) *grid
- func Col16(args ...any) *grid
- func Compact(args ...any) *text
- func Deleted(args ...any) *text
- func DismissibleTag(args ...any) *tag
- func Dropdown(helperText string, args ...any) *dropdown
- func DropdownItem(args ...any) *dropdownItem
- func Em(args ...any) *text
- func Form(args ...any) *form
- func FormGroup(args ...any) *formGroup
- func GoName(eventType string) string
- func Grid(args ...any) *grid
- func GridCondensed(args ...any) *grid
- func GridFullWidth(args ...any) *grid
- func GridNarrow(args ...any) *grid
- func Head(level int, args ...any) *text
- func Header(args ...any) *navgroup
- func HeaderNavGlobal(args ...any) *navglobal
- func HeaderNavItem(href string, args ...any) *navitem
- func HeaderPanel(args ...any) *panel
- func Highlighted(args ...any) *text
- func Icon(name IconName, args ...any) *icon
- func Input(args ...any) *input
- func IsBooleanAttr(a Attr) bool
- func IsComponentKind(a Attr) bool
- func IsSize(a Attr) bool
- func IsTheme(a Attr) bool
- func Lead(args ...any) *text
- func Link(href string, args ...any) *link
- func List(args ...any) *list
- func ListItem(args ...any) *list
- func Markdown(text string, args ...any) mvc.View
- func NumberInput(args ...any) *numberInput
- func OperationalTag(args ...any) *tag
- func OrderedList(args ...any) *list
- func OverflowMenu(args ...any) *overflowMenu
- func OverflowMenuItem(args ...any) *overflowMenuItem
- func Page(args ...any) *container
- func Pagination(args ...any) *pagination
- func Para(args ...any) *text
- func Section(args ...any) *container
- func SecureInput(args ...any) *input
- func SideNav(args ...any) *navgroup
- func SideNavGroup(title string, args ...any) *navitem
- func SideNavGroupItem(href string, args ...any) *navitem
- func SideNavLink(href string, args ...any) *navitem
- func Smaller(args ...any) *text
- func Strong(args ...any) *text
- func StructuredList(args ...any) *structuredList
- func StructuredListCell(args ...any) *structuredListCell
- func StructuredListHeader(args ...any) *structuredListHeader
- func StructuredListHeaderCell(args ...any) *structuredListHeaderCell
- func StructuredListRow(args ...any) *structuredListRow
- func Table(args ...any) *table
- func TableHeader(args ...any) *tableHeader
- func TableRow(args ...any) *tableRow
- func TableToolbar(args ...any) *tableToolbar
- func TableToolbarContent(args ...any) *tableToolbarContent
- func TableToolbarSearch(args ...any) *tableToolbarSearch
- func Tag(args ...any) *tag
- func TagGroup(args ...any) *tagGroup
- func Tile(args ...any) *tile
- func TileDecorator(args ...any) *tile
- func With(attrs ...Attr) []mvc.Opt
- func WithBackground(color string) mvc.Opt
- func WithCodeCopyText(text string) mvc.Opt
- func WithCodeFeedback(msg string) mvc.Opt
- func WithFill() mvc.Opt
- func WithHeight(height string) mvc.Opt
- type Attr
- type CheckboxOrientation
- type CheckboxState
- type IconName
- type IconSize
- type MarkdownLinkResolver
- type MarkdownOpt
Constants ¶
const ( EventClick = "click" EventInput = "input" EventChange = "change" EventInvalid = "invalid" EventHover = "mouseenter" EventNoHover = "pointerleave" // mouseleave unreliable on web components; pointerleave respects pointer capture EventFocus = "focus" EventNoFocus = "focusout" // blur does not bubble; focusout does, crossing the shadow-DOM boundary EventHoverBubbled = "pointerover" // bubbling hover signal for container-level listeners EventNoHoverBubbled = "pointerout" // bubbling hover-exit signal for container-level listeners EventFocusBubbled = "focusin" // bubbling focus signal for container-level listeners EventSectionToggle = "cds-side-nav-menu-toggled" EventSectionToggling = "cds-side-nav-menu-beingtoggled" EventSelected = "cds-dropdown-selected" EventPaginationChanged = "cds-pagination-changed-current" EventPaginationPageSize = "cds-page-sizes-select-changed" EventOverflowMenuItemClick = "cds-overflow-menu-item-clicked" EventTagDismissibleClosed = "cds-dismissible-tag-closed" EventTagOperationalSelected = "cds-operational-tag-selected" )
Event type constants for Carbon views.
const ( ViewSection = "mvc-cds-section" ViewForm = "mvc-cds-form" ViewFormGroup = "mvc-cds-form-group" ViewInput = "mvc-cds-input" ViewSecureInput = "mvc-cds-secure-input" ViewNumberInput = "mvc-cds-number-input" ViewLink = "mvc-cds-link" ViewText = "mvc-cds-text" ViewBlockquote = "mvc-cds-blockquote" ViewList = "mvc-cds-list" ViewMarkdown = "mvc-cds-markdown" ViewButton = "mvc-cds-button" ViewButtonGroup = "mvc-cds-button-group" ViewIcon = "mvc-cds-icon" ViewHeaderPanel = "mvc-cds-header-panel" ViewOverflowMenu = "mvc-cds-overflow-menu" ViewOverflowItem = "mvc-cds-overflow-menu-item" ViewGrid = "mvc-cds-grid" ViewTile = "mvc-cds-tile" ViewStructuredList = "mvc-cds-structured-list" ViewStructuredListHead = "mvc-cds-structured-list-head" ViewStructuredListRow = "mvc-cds-structured-list-row" ViewStructuredListCell = "mvc-cds-structured-list-cell" ViewStructuredListTH = "mvc-cds-structured-list-header-cell" ViewTable = "mvc-cds-table" ViewTableHeader = "mvc-cds-table-header" ViewTableRow = "mvc-cds-table-row" ViewTableToolbar = "mvc-cds-table-toolbar" ViewTableToolbarContent = "mvc-cds-table-toolbar-content" ViewTableToolbarSearch = "mvc-cds-table-toolbar-search" ViewPagination = "mvc-cds-pagination" ViewCheckbox = "mvc-cds-checkbox" ViewCheckboxGroup = "mvc-cds-checkbox-group" ViewDropdown = "mvc-cds-dropdown" ViewDropdownItem = "mvc-cds-dropdown-item" ViewCodeSnippet = "mvc-cds-code-snippet" ViewTag = "mvc-cds-tag" ViewTagGroup = "mvc-cds-tag-group" ViewDismissibleTag = "mvc-cds-dismissible-tag" ViewOperationalTag = "mvc-cds-operational-tag" )
The view names for Carbon Design System components
Variables ¶
var DocsFS embed.FS
DocsFS embeds the Markdown documentation files for Carbon components.
var EventName = map[string]string{ EventClick: "EventClick", EventInput: "EventInput", EventChange: "EventChange", EventInvalid: "EventInvalid", EventHover: "EventHover", EventNoHover: "EventNoHover", EventFocus: "EventFocus", EventNoFocus: "EventNoFocus", EventHoverBubbled: "EventHover", EventNoHoverBubbled: "EventNoHover", EventFocusBubbled: "EventFocus", EventSectionToggle: "EventSectionToggle", EventSectionToggling: "EventSectionToggling", EventSelected: "EventSelected", EventPaginationChanged: "EventPaginationChanged", EventPaginationPageSize: "EventPaginationPageSize", EventOverflowMenuItemClick: "EventOverflowMenuItemClick", EventTagDismissibleClosed: "EventTagDismissibleClosed", EventTagOperationalSelected: "EventTagOperationalSelected", // contains filtered or unexported fields }
EventName maps a raw DOM event type string to its Go constant name. Returns the raw string if no mapping is found.
Functions ¶
func Blockquote ¶
func Blockquote(args ...any) *blockquote
Blockquote returns a figure containing a styled blockquote and optional label.
func Button ¶
func Button(args ...any) *button
Button returns a <cds-button> web component. Use With() to apply kind, size, and other attributes
func ButtonGroup ¶
func ButtonGroup(args ...any) *buttonGroup
ButtonGroup returns a <cds-button-group> web component that arranges buttons horizontally with correct Carbon spacing.
func Checkbox ¶
func Checkbox(args ...any) *checkbox
Checkbox returns a <cds-checkbox> web component. An optional leading string argument sets the label-text attribute.
carbon.Checkbox("Enabled")
func CheckboxGroup ¶
CheckboxGroup returns a <cds-checkbox-group> web component. helperText is shown below the group; pass an empty string for none.
func ClassForTheme ¶
ClassForTheme returns the CSS class name for a theme Attr (e.g. "cds--g100"). Returns an empty string if a is not a theme Attr.
func CloseButton ¶
func CloseButton(args ...any) *button
CloseButton returns a ghost icon-only button with a close (X) icon.
func Code ¶
func Code(args ...any) *codeSnippet
Code returns a <cds-code-snippet type="inline"> suitable for embedding short code fragments within a sentence.
carbon.Code("go build ./...")
func CodeBlock ¶
func CodeBlock(args ...any) *codeSnippet
CodeBlock returns a <cds-code-snippet type="multi"> — a multi-line code block that collapses long content behind a "Show more" button.
carbon.CodeBlock("line1\nline2\nline3")
func CodeSnippet ¶
func CodeSnippet(args ...any) *codeSnippet
CodeSnippet returns a <cds-code-snippet type="single"> — a one-line code block with a copy button and horizontal scroll on overflow.
carbon.CodeSnippet("GOOS=js GOARCH=wasm go build .")
func Compact ¶
func Compact(args ...any) *text
Compact returns a <p> styled with the Carbon body-compact-01 type token.
func DismissibleTag ¶
func DismissibleTag(args ...any) *tag
DismissibleTag returns a <cds-dismissible-tag> web component. An optional leading string sets the text attribute.
func Dropdown ¶
Dropdown returns a <cds-dropdown> web component. helperText is shown below the dropdown; pass an empty string for none.
func DropdownItem ¶
func DropdownItem(args ...any) *dropdownItem
DropdownItem returns a <cds-dropdown-item> web component.
func FormGroup ¶
func FormGroup(args ...any) *formGroup
FormGroup returns a <cds-form-group> web component.
func GoName ¶
GoName returns the Go constant name for a raw DOM event type, or the raw event type string itself if no mapping exists.
func Grid ¶
func Grid(args ...any) *grid
Grid returns a Carbon 16-column CSS grid container (cds--css-grid).
func GridCondensed ¶
func GridCondensed(args ...any) *grid
GridCondensed returns a condensed-gutter CSS grid variant (1px gutters).
func GridFullWidth ¶
func GridFullWidth(args ...any) *grid
GridFullWidth returns a full-width CSS grid that stretches edge-to-edge.
func GridNarrow ¶
func GridNarrow(args ...any) *grid
GridNarrow returns a narrow-gutter CSS grid variant.
func Head ¶
Head returns an <h1>–<h6> styled with the matching Carbon heading token. Level 1 maps to cds--heading-06 (largest); level 6 to cds--heading-01.
func HeaderNavGlobal ¶
func HeaderNavGlobal(args ...any) *navglobal
HeaderNavGlobal returns the right-aligned global actions container for a header.
func HeaderNavItem ¶
HeaderNavItem returns a <cds-header-nav-item> link for the header menu bar.
func HeaderPanel ¶
func HeaderPanel(args ...any) *panel
HeaderPanel returns a <cds-header-panel> UI shell right panel.
func Icon ¶
Icon returns a <cds-icon> web component backed by the bundled icon registry. Only the icons exported by this package are guaranteed to resolve.
func IsBooleanAttr ¶
IsBooleanAttr reports whether a is represented as a boolean HTML attribute.
func IsComponentKind ¶
IsComponentKind reports whether a is a component kind (kind= attribute).
func Lead ¶
func Lead(args ...any) *text
Lead returns a <p> styled with the Carbon body-02 type token for larger, more prominent introductory copy.
func Link ¶
Link returns a <cds-link> web component. The href is always applied as the first argument; use With() for size and inline presentation, and pass Icon(...) to include a slotted Carbon icon.
func NumberInput ¶
func NumberInput(args ...any) *numberInput
NumberInput returns a <cds-number-input> web component.
func OperationalTag ¶
func OperationalTag(args ...any) *tag
OperationalTag returns a <cds-operational-tag> web component. An optional leading string sets the text attribute.
func OrderedList ¶
func OrderedList(args ...any) *list
OrderedList returns an ordered list (<ol>) view.
func OverflowMenu ¶
func OverflowMenu(args ...any) *overflowMenu
OverflowMenu returns a <cds-overflow-menu> web component.
func OverflowMenuItem ¶
func OverflowMenuItem(args ...any) *overflowMenuItem
OverflowMenuItem returns a <cds-overflow-menu-item> web component.
func Page ¶
func Page(args ...any) *container
Page returns a plain <div> view with no cds--content padding, suitable for use as a per-page wrapper inside the main content Section.
func Pagination ¶
func Pagination(args ...any) *pagination
Pagination returns a <cds-pagination> web component.
func Para ¶
func Para(args ...any) *text
Para returns a <p> styled with the Carbon body-01 type token.
func Section ¶
func Section(args ...any) *container
Section returns a <section class="cds--content"> layout container.
func SecureInput ¶
func SecureInput(args ...any) *input
SecureInput returns a <cds-password-input> web component. It shares the same public methods as Input.
func SideNavGroup ¶
SideNavGroup returns a <cds-side-nav-menu> collapsible navigation group.
func SideNavGroupItem ¶
SideNavGroupItem returns a <cds-side-nav-menu-item> for a SideNavGroup.
func SideNavLink ¶
SideNavLink returns a <cds-side-nav-link> top-level navigation entry.
func StructuredList ¶
func StructuredList(args ...any) *structuredList
StructuredList returns a Carbon structured list with a header slot and body slot.
func StructuredListCell ¶
func StructuredListCell(args ...any) *structuredListCell
StructuredListCell returns a structured list body cell.
func StructuredListHeader ¶
func StructuredListHeader(args ...any) *structuredListHeader
StructuredListHeader returns a structured list header row.
func StructuredListHeaderCell ¶
func StructuredListHeaderCell(args ...any) *structuredListHeaderCell
StructuredListHeaderCell returns a structured list header cell.
func StructuredListRow ¶
func StructuredListRow(args ...any) *structuredListRow
StructuredListRow returns a structured list body row.
func TableHeader ¶
func TableHeader(args ...any) *tableHeader
TableHeader returns a table header row.
func TableToolbar ¶
func TableToolbar(args ...any) *tableToolbar
TableToolbar returns a <cds-table-toolbar> web component.
Search children are inserted directly into the toolbar. Any other content is automatically grouped into a <cds-table-toolbar-content> wrapper so call sites can pass buttons and menus directly.
func TableToolbarContent ¶
func TableToolbarContent(args ...any) *tableToolbarContent
TableToolbarContent returns a <cds-table-toolbar-content> wrapper.
func TableToolbarSearch ¶
func TableToolbarSearch(args ...any) *tableToolbarSearch
TableToolbarSearch returns a <cds-table-toolbar-search> web component.
func TagGroup ¶
func TagGroup(args ...any) *tagGroup
TagGroup returns a container for one or more tags. Child tag events bubble to the group, allowing group-level observation.
func Tile ¶
func Tile(args ...any) *tile
Tile returns a <cds-tile> web component — a static content container analogous to Bootstrap's Card.
carbon.Tile(carbon.Head(3, "Title"), carbon.Para("Body text"))
func TileDecorator ¶
func TileDecorator(args ...any) *tile
TileDecorator returns a <cds-tile> for backward compatibility. Carbon's tile decorator treatment is supplied via slotted content assigned to the `decorator` slot rather than a host attribute.
func With ¶
With converts one or more Attr constants into mvc.Opt values and returns them as a []mvc.Opt slice. Because gatherOpts flattens []mvc.Opt, the result can be passed directly as an argument to any constructor:
carbon.Button(carbon.With(carbon.KindPrimary, carbon.SizeLarge), "Click me") carbon.Tile(carbon.With(carbon.ThemeG90), "Dark tile")
When a theme Attr is included, all other theme classes are removed first so that switching themes via Apply is always clean.
func WithBackground ¶
WithBackground returns an mvc.Opt that sets a tile background to the given CSS colour value. The tile wrapper translates this into the --cds-layer custom property.
carbon.Tile(carbon.WithBackground("#d0e2ff"), carbon.Head(3, "Title"))
func WithCodeCopyText ¶
WithCodeCopyText returns an option that overrides the text placed on the clipboard. When empty, the component copies its own visible content.
func WithCodeFeedback ¶
WithCodeFeedback returns an option that overrides the temporary copied feedback message shown by the snippet. When empty, the component default is used.
func WithHeight ¶
WithHeight returns an mvc.Opt that sets a fixed host height.
Types ¶
type Attr ¶
type Attr string
Attr is a typed attribute value applied to Carbon components (kind=, size=, data-carbon-theme=, etc.).
const ( KindPrimary Attr = "primary" KindSecondary Attr = "secondary" KindTertiary Attr = "tertiary" KindGhost Attr = "ghost" KindDanger Attr = "danger" KindDangerTertiary Attr = "danger-tertiary" KindDangerGhost Attr = "danger-ghost" )
Button / general component kinds
const ( KindSuccess Attr = "success" KindInfo Attr = "info" KindInfoSquare Attr = "info-square" KindWarning Attr = "warning" KindWarningAlt Attr = "warning-alt" KindError Attr = "error" )
Notification / status kinds (also used by Tag, InlineNotification, etc.)
const ( TagRed Attr = "red" TagMagenta Attr = "magenta" TagPurple Attr = "purple" TagBlue Attr = "blue" TagCyan Attr = "cyan" TagTeal Attr = "teal" TagGreen Attr = "green" TagGray Attr = "gray" TagCoolGray Attr = "cool-gray" TagWarmGray Attr = "warm-gray" TagHighContrast Attr = "high-contrast" TagOutline Attr = "outline" )
Tag types.
const ( SizeExtraSmall Attr = "xs" SizeSmall Attr = "sm" SizeMedium Attr = "md" SizeLarge Attr = "lg" SizeExtraLarge Attr = "xl" Size2XLarge Attr = "2xl" )
Component sizes
const ( IconSize16 Attr = "16" IconSize20 Attr = "20" IconSize24 Attr = "24" IconSize32 Attr = "32" )
Icon sizes.
const ( CheckboxOrientationHorizontal Attr = "horizontal" CheckboxOrientationVertical Attr = "vertical" )
Checkbox group orientations.
Structured list appearance flags.
Code snippet appearance flags.
const ( ListDisc Attr = "disc" ListCircle Attr = "circle" ListSquare Attr = "square" ListDecimal Attr = "decimal" ListLowerAlpha Attr = "lower-alpha" ListUpperAlpha Attr = "upper-alpha" ListLowerRoman Attr = "lower-roman" ListUpperRoman Attr = "upper-roman" )
List style types.
const ( ThemeWhite Attr = "white" // default light theme → .cds--white ThemeG10 Attr = "g10" // light grey → .cds--g10 ThemeG90 Attr = "g90" // dark grey → .cds--g90 ThemeG100 Attr = "g100" // near-black → .cds--g100 )
Carbon colour themes — applied as CSS class (.cds--white, .cds--g10, etc.).
const (
LinkInline Attr = "inline"
)
Link-specific flags.
type CheckboxOrientation ¶
type CheckboxOrientation = Attr
CheckboxOrientation determines how a checkbox group lays out its children. It is an Attr so it can be applied with With().
type CheckboxState ¶
type CheckboxState string
CheckboxState represents the tri-state value of a checkbox.
`undefined` maps to Carbon's indeterminate state.
const ( CheckboxStateUndefined CheckboxState = "undefined" CheckboxStateFalse CheckboxState = "false" CheckboxStateTrue CheckboxState = "true" )
type IconName ¶
type IconName string
IconName identifies an icon bundled into the Carbon example registry. The values match the underlying Carbon icon names.
const ( IconAdd IconName = "add" IconArrowRight IconName = "arrow-right" IconCheckmark IconName = "checkmark" IconClose IconName = "close" IconFavorite IconName = "favorite" IconLaunch IconName = "launch" IconLogoGithub IconName = "logo--github" IconSearch IconName = "search" IconSettings IconName = "settings" IconUserAvatar IconName = "user--avatar" IconWarningFilled IconName = "warning--filled" )
Common icon name constants for convenience.
type MarkdownLinkResolver ¶
MarkdownLinkResolver rewrites markdown link destinations before they are rendered.
type MarkdownOpt ¶
type MarkdownOpt func(*markdownConfig)
MarkdownOpt configures markdown-specific rendering behaviour.
func WithMarkdownLinkResolver ¶
func WithMarkdownLinkResolver(fn MarkdownLinkResolver) MarkdownOpt
WithMarkdownLinkResolver applies a link resolver to markdown links.
Source Files
¶
- attr.go
- blockquote.go
- button.go
- button_group.go
- checkbox.go
- checkbox_group.go
- code.go
- code_block.go
- code_snippet.go
- compact.go
- container.go
- deleted.go
- dismissible_tag.go
- dropdown.go
- dropdown_item.go
- em.go
- embed.go
- event.go
- form.go
- form_group.go
- form_invalid.go
- grid.go
- head.go
- header.go
- header_nav_global.go
- header_nav_item.go
- highlighted.go
- icon.go
- input.go
- input_change.go
- input_validity.go
- lead.go
- link.go
- list.go
- list_item.go
- markdown.go
- nav.go
- number_input.go
- number_input_validity.go
- operational_tag.go
- ordered_list.go
- overflow_menu.go
- overflow_menu_item.go
- page.go
- pagination.go
- panel.go
- para.go
- section.go
- secure_input.go
- side_nav.go
- side_nav_group.go
- side_nav_group_item.go
- side_nav_link.go
- smaller.go
- strong.go
- structured_list.go
- structured_list_cell.go
- structured_list_change.go
- structured_list_header.go
- structured_list_header_cell.go
- structured_list_row.go
- table.go
- table_header.go
- table_row.go
- table_toolbar.go
- table_toolbar_content.go
- table_toolbar_search.go
- tag.go
- tag_group.go
- text.go
- tile.go
- tile_decorator.go
- view.go