carbon

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Carbon Package

The pkg/carbon package provides Carbon Design System view wrappers on top of the local pkg/mvc layer. Most files in this directory follow the same construction pattern so new components stay predictable and existing ones are easy to extend.

View Structure

Carbon views are built in four layers:

  1. A registered view name in view.go
  2. A concrete Go type which embeds the shared base
  3. An init() function which registers the view with mvc.RegisterView
  4. One or more exported constructors which call mvc.NewView

The shared base type stores the inner mvc.View implementation:

type base struct {
    mvc.View
}

That embedded field is wired by setView, which means each Carbon component only needs to embed base and can then rely on the common MVC behavior.

Common Pattern

Most components look like this:

type button struct{ base }

func init() {
    mvc.RegisterView(ViewButton, func(element dom.Element) mvc.View {
        return mvc.NewViewWithElement(new(button), element, setView)
    })
}

func Button(args ...any) *button {
    return mvc.NewView(new(button), ViewButton, "cds-button", setView, args).(*button)
}

This pattern does two different jobs:

  • mvc.RegisterView(... NewViewWithElement ...) reconstructs a Carbon view from an existing DOM element
  • mvc.NewView(...) creates a fresh DOM element or template-backed subtree and returns the concrete Carbon type

Constructors accept a mixed argument list because mvc.NewView splits arguments into:

  • mvc.Opt values such as mvc.WithClass, mvc.WithAttr, mvc.WithStyle, or mvc.WithID
  • Carbon attribute helpers returned by carbon.With(...)
  • child views
  • DOM elements
  • strings and other content inserted into the default content slot

For example:

carbon.Button(
    carbon.With(carbon.KindPrimary, carbon.SizeLarge),
    mvc.WithID("save"),
    "Save",
)

carbon.With(...) returns []mvc.Opt, so it can be passed directly into any constructor.

Simple Views

Simple views render from a single tag or custom element name. Examples include:

Typical templates for simple views are:

  • a native tag such as "DIV", "P", or "SECTION"
  • a Carbon web component tag such as "cds-button"

Examples:

func Section(args ...any) *container {
    return mvc.NewView(new(container), ViewSection, "SECTION", setView,
        mvc.WithClass("cds--content"), args).(*container)
}

func Head(level int, args ...any) *text {
    tag := fmt.Sprintf("H%d", level)
    cls := fmt.Sprintf("cds--heading-%02d", 7-level)
    return mvc.NewView(new(text), ViewText, tag, setView,
        mvc.WithClass(cls), args).(*text)
}

These constructors mostly differ only in:

  • the registered view name
  • the root tag or Carbon element
  • default classes or attributes
  • any extra validation or argument normalization

Supporting helper methods should stay close to that construction logic. Use them to normalize constructor arguments or to adapt Carbon-specific DOM details behind the public view API. For example, button.go normalizes icon arguments so icon children are moved into the slot="icon" position expected by Carbon.

Composite Views And Slots

Some Carbon views use an HTML template instead of a single tag. These templates declare named slots with data-slot, and the underlying MVC layer keeps track of those slots.

Examples:

The table component is representative:

const templateTable = `
    <cds-table size="sm">
        <cds-table-head data-slot="header"></cds-table-head>
        <cds-table-body data-slot="body"></cds-table-body>
    </cds-table>
`

func Table(args ...any) *table {
    return mvc.NewView(new(table), ViewTable, templateTable, setView, args).(*table)
}

This lets methods target specific regions of the component:

  • Content(...) writes to the default body slot
  • ReplaceSlot(...) replaces a named slot
  • ReplaceSlotChildren(...) replaces the children inside a named slot

Use a template-backed view when a component needs a stable internal structure rather than a single root element.

Styling And Attributes

Carbon-specific appearance values are defined in attr.go as typed Attr constants.

Examples include:

  • kinds such as KindPrimary and KindGhost
  • sizes such as SizeSmall and SizeLarge
  • themes such as ThemeWhite and ThemeG100
  • component-specific flags such as LinkInline or CodeWrapText

carbon.With(...) converts those typed values into mvc.Opt values. Most attrs become HTML attributes such as kind, size, or type. Theme attrs are handled as CSS classes like cds--g10.

Component State

View state should be exposed through the interface contracts in state.go, not through ad hoc component-specific mutation methods.

Use the existing MVC state interfaces when a Carbon component has readable or writable state, for example:

  • mvc.LabelState
  • mvc.ValueState
  • mvc.ActiveState
  • mvc.EnabledState
  • mvc.VisibleState
  • mvc.PaginationState
  • mvc.ActiveGroup, mvc.EnabledGroup, and mvc.VisibleGroup for container-managed state

That means state should be accessed and written through the established getter and setter pairs such as:

  • Label() and SetLabel(...)
  • Value() and SetValue(...)
  • Active() and SetActive(...)
  • Enabled() and SetEnabled(...)
  • Visible() and SetVisible(...)

Do not add custom methods whose only purpose is to alter state when an existing mvc/state.go contract already covers it. For example, prefer implementing mvc.EnabledState over introducing a separate method such as Disable() or SetDisabled(...), and prefer mvc.VisibleState over custom show or hide APIs.

If a component needs state, implement the matching MVC interface, add the corresponding interface assertion in the view file, and keep the DOM mapping inside the standard Set... method. This keeps Carbon components interchangeable, predictable, and easy for controllers to work with generically.

Events

Carbon event names are defined in event.go.

Those constants are the public event surface for Carbon views and should be used when:

  • registering supported events in mvc.RegisterView(...)
  • attaching listeners with AddEventListener(...)
  • bridging or normalizing Carbon custom events into package-level event names

A Carbon view component may emit events, either from the component itself or by exposing events from child components that are part of the view composition. Event targets should remain at the view boundary:

  • the event target may be the component's own root element
  • the event target may be a child component when that child is part of the containing view
  • the event target should not be an implementation detail inside a shadow root

In practice, that means Carbon wrappers should normalize or bridge events so controllers observe component-level targets rather than private internal nodes created by Carbon web components. If an event originates from internal Carbon markup, expose it from the wrapping view or from a child view that is already part of the public view structure. Event registration in mvc.RegisterView(...) should describe that public event surface, not shadow-DOM implementation details.

This keeps event handling stable even when Carbon internals change, and it ensures application code works with views and components instead of shadow-DOM details.

When adding a new Carbon view, follow this order:

  1. Add a new View... constant in view.go
  2. Create a concrete type embedding base
  3. Register it in init() with mvc.RegisterView(... mvc.NewViewWithElement(...))
  4. Add an exported constructor that calls mvc.NewView
  5. Use a single tag for simple components, or a template with data-slot markers for structured components
  6. Add typed behavior methods only when the component needs more than plain content and attributes
  7. Add or update the per-component markdown doc next to the Go file

File Layout

The package is organized roughly like this:

  • view.go: registered view names and shared base wiring
  • attr.go: typed Carbon attrs and With(...)
  • component *.go files: concrete constructors and behavior
  • component *.md files: usage-focused docs for each exported view

If you need an example to copy, start with a simple file such as grid.go or a structured one such as table.go, depending on whether the new component needs slots.

Documentation

Index

Constants

View Source
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.

View Source
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"
	ViewNav                 = "mvc-cds-nav"
	ViewNavGlobal           = "mvc-cds-nav-global"
	ViewHeaderPanel         = "mvc-cds-header-panel"
	ViewOverflowMenu        = "mvc-cds-overflow-menu"
	ViewOverflowItem        = "mvc-cds-overflow-menu-item"
	ViewNavItem             = "mvc-cds-navitem"
	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

View Source
var DocsFS embed.FS

DocsFS embeds the Markdown documentation files for Carbon components.

View Source
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

func CheckboxGroup(helperText string, args ...any) *checkboxGroup

CheckboxGroup returns a <cds-checkbox-group> web component. helperText is shown below the group; pass an empty string for none.

func ClassForTheme

func ClassForTheme(a Attr) string

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 Col

func Col(n int, args ...any) *grid

Col spans n of 16 columns, where n must be between 1 and 16.

func Col1

func Col1(args ...any) *grid

Col1 spans 1 of 16 columns.

func Col2

func Col2(args ...any) *grid

Col2 spans 2 of 16 columns.

func Col4

func Col4(args ...any) *grid

Col4 spans 4 of 16 columns (one quarter).

func Col6

func Col6(args ...any) *grid

Col6 spans 6 of 16 columns.

func Col8

func Col8(args ...any) *grid

Col8 spans 8 of 16 columns (one half).

func Col10

func Col10(args ...any) *grid

Col10 spans 10 of 16 columns.

func Col12

func Col12(args ...any) *grid

Col12 spans 12 of 16 columns (three quarters).

func Col16

func Col16(args ...any) *grid

Col16 spans all 16 columns (full width).

func Compact

func Compact(args ...any) *text

Compact returns a <p> styled with the Carbon body-compact-01 type token.

func Deleted

func Deleted(args ...any) *text

Deleted returns inline deleted text.

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(helperText string, args ...any) *dropdown

Dropdown returns a <cds-dropdown> web component. helperText is shown below the dropdown; pass an empty string for none.

func DropdownItem(args ...any) *dropdownItem

DropdownItem returns a <cds-dropdown-item> web component.

func Em

func Em(args ...any) *text

Em returns inline emphasized text.

func Form

func Form(args ...any) *form

Form returns a <cds-form> web component.

func FormGroup

func FormGroup(args ...any) *formGroup

FormGroup returns a <cds-form-group> web component.

func GoName

func GoName(eventType string) string

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(level int, args ...any) *text

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 Header(args ...any) *navgroup

Header returns a <cds-header> UI shell header.

func HeaderNavGlobal

func HeaderNavGlobal(args ...any) *navglobal

HeaderNavGlobal returns the right-aligned global actions container for a header.

func HeaderNavItem

func HeaderNavItem(href string, args ...any) *navitem

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 Highlighted

func Highlighted(args ...any) *text

Highlighted returns inline highlighted text.

func Icon

func Icon(name IconName, args ...any) *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 Input

func Input(args ...any) *input

Input returns a <cds-text-input> web component.

func IsBooleanAttr

func IsBooleanAttr(a Attr) bool

IsBooleanAttr reports whether a is represented as a boolean HTML attribute.

func IsComponentKind

func IsComponentKind(a Attr) bool

IsComponentKind reports whether a is a component kind (kind= attribute).

func IsSize

func IsSize(a Attr) bool

IsSize reports whether a is a size value (size= attribute).

func IsTheme

func IsTheme(a Attr) bool

IsTheme reports whether a is a theme (applied as CSS class, not 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(href string, args ...any) *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 List

func List(args ...any) *list

List returns an unordered list (<ul>) view.

func ListItem

func ListItem(args ...any) *list

ListItem returns a list item (<li>) view.

func Markdown

func Markdown(text string, args ...any) mvc.View

Markdown creates a block-level markdown view using a DIV root element.

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 SideNav

func SideNav(args ...any) *navgroup

SideNav returns a <cds-side-nav> shell panel.

func SideNavGroup

func SideNavGroup(title string, args ...any) *navitem

SideNavGroup returns a <cds-side-nav-menu> collapsible navigation group.

func SideNavGroupItem

func SideNavGroupItem(href string, args ...any) *navitem

SideNavGroupItem returns a <cds-side-nav-menu-item> for a SideNavGroup.

func SideNavLink(href string, args ...any) *navitem

SideNavLink returns a <cds-side-nav-link> top-level navigation entry.

func Smaller

func Smaller(args ...any) *text

Smaller returns inline smaller supporting text.

func Strong

func Strong(args ...any) *text

Strong returns inline strongly emphasized text.

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 Table

func Table(args ...any) *table

Table returns a minimal Carbon-styled data table.

func TableHeader

func TableHeader(args ...any) *tableHeader

TableHeader returns a table header row.

func TableRow

func TableRow(args ...any) *tableRow

TableRow returns a table body 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 Tag

func Tag(args ...any) *tag

Tag returns a <cds-tag> 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

func With(attrs ...Attr) []mvc.Opt

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

func WithBackground(color string) mvc.Opt

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

func WithCodeCopyText(text string) mvc.Opt

WithCodeCopyText returns an option that overrides the text placed on the clipboard. When empty, the component copies its own visible content.

func WithCodeFeedback

func WithCodeFeedback(msg string) mvc.Opt

WithCodeFeedback returns an option that overrides the temporary copied feedback message shown by the snippet. When empty, the component default is used.

func WithFill

func WithFill() mvc.Opt

WithFill returns an mvc.Opt that makes a tile fill the width of its container.

func WithHeight

func WithHeight(height string) mvc.Opt

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.

const (
	StructuredListCondensed Attr = "condensed"
	StructuredListFlush     Attr = "flush"
)

Structured list appearance flags.

const (
	CodeWrapText       Attr = "wrap-text"
	CodeHideCopyButton Attr = "hide-copy-button"
)

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 IconSize

type IconSize = Attr

IconSize is the rendered size of a Carbon icon.

type MarkdownLinkResolver

type MarkdownLinkResolver func(string) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL