cupertino

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cupertino provides an Apple Human Interface Guidelines (HIG) theme.

The Cupertino theme follows Apple's design language with system blue accent colors, rounded pill-shaped buttons, iOS-style toggle switches for checkboxes, thin auto-hiding scrollbars, sheet-style dialogs, and segmented control tab bars.

Creating a Theme

Create a theme with the default system blue accent:

theme := cupertino.NewTheme()
accent := theme.Colors.Accent
radius := theme.Radius

Or customize the accent color:

theme := cupertino.NewTheme(cupertino.WithAccentColor(widget.Hex(0x34C759)))

Light and Dark Schemes

Both light and dark themes are available:

lightTheme := cupertino.NewTheme()
darkTheme := cupertino.NewDarkTheme()

Component Painters

The package provides painter implementations that render UI components according to Apple HIG specifications. Painters implement the interfaces defined in core packages and can be injected into widgets:

Example:

btn := button.New(
    button.Text("Submit"),
    button.PainterOpt(cupertino.ButtonPainter{Theme: cupertinoTheme}),
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgePainter added in v0.1.35

type BadgePainter struct {
	Theme *Theme // nil uses default Cupertino fallback
}

BadgePainter renders badges using Apple HIG (Cupertino) design tokens. Cupertino badges use System Red for the background with white text, matching the iOS/macOS notification badge style.

If Theme is nil, BadgePainter falls back to the default Cupertino light palette.

func (BadgePainter) PaintBadge added in v0.1.35

func (p BadgePainter) PaintBadge(canvas widget.Canvas, ps badge.PaintState)

PaintBadge renders a badge according to Cupertino specifications. It delegates to the core badge.DefaultPainter with Cupertino-derived colors.

type ButtonPainter

type ButtonPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

ButtonPainter renders buttons using Apple HIG design tokens. Cupertino buttons use rounded pill shapes with system blue fills.

Button variants map to iOS styles:

  • Filled: rounded rect with accent color fill (primary CTA)
  • Outlined: rounded rect with accent color border
  • TextOnly: text-only button with accent color text
  • Tonal: rounded rect with light accent tint fill

If Theme is nil, ButtonPainter falls back to the default system blue palette.

func (ButtonPainter) ButtonFontSize added in v0.1.37

func (ButtonPainter) ButtonFontSize(size button.Size) float32

ButtonFontSize returns the Cupertino font size for the given button size.

func (ButtonPainter) ButtonHeight added in v0.1.37

func (ButtonPainter) ButtonHeight(size button.Size) float32

ButtonHeight returns the Cupertino height for the given button size.

func (ButtonPainter) ButtonPadding added in v0.1.37

func (ButtonPainter) ButtonPadding(size button.Size) (float32, float32)

ButtonPadding returns the Cupertino horizontal and vertical padding.

func (ButtonPainter) ButtonRadius added in v0.1.37

func (ButtonPainter) ButtonRadius() float32

ButtonRadius returns the Cupertino default corner radius.

func (ButtonPainter) PaintButton

func (p ButtonPainter) PaintButton(canvas widget.Canvas, state button.PaintState)

PaintButton renders a button according to Apple HIG specifications.

type CheckboxPainter

type CheckboxPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

CheckboxPainter renders checkboxes as iOS-style toggle switches. Instead of the traditional square checkbox, Cupertino uses a pill-shaped toggle switch that slides between on/off states.

The toggle track is a rounded pill. When checked (on), the track fills with the accent color and the thumb knob slides to the right. When unchecked (off), the track shows a gray outline.

If Theme is nil, CheckboxPainter falls back to the default system blue palette.

func (CheckboxPainter) CheckboxBoxSize added in v0.1.37

func (CheckboxPainter) CheckboxBoxSize() float32

CheckboxBoxSize returns the Cupertino toggle track width. The Cupertino checkbox renders as a toggle switch, so the "box size" represents the track width for layout purposes.

func (CheckboxPainter) CheckboxFontSize added in v0.1.37

func (CheckboxPainter) CheckboxFontSize() float32

CheckboxFontSize returns the Cupertino label font size.

func (CheckboxPainter) CheckboxLabelGap added in v0.1.37

func (CheckboxPainter) CheckboxLabelGap() float32

CheckboxLabelGap returns the Cupertino gap between toggle and label.

func (CheckboxPainter) PaintCheckbox

func (p CheckboxPainter) PaintCheckbox(canvas widget.Canvas, state checkbox.PaintState)

PaintCheckbox renders a checkbox as an iOS toggle switch.

type ChipPainter added in v0.1.35

type ChipPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

ChipPainter renders chips using Apple HIG design tokens. It maps chip states to the Cupertino color scheme: system blue for the selected state (pill-shaped tag), separator for the unselected border.

If Theme is nil, ChipPainter falls back to the default system blue palette.

func (ChipPainter) ChipFontSize added in v0.1.37

func (ChipPainter) ChipFontSize() float32

ChipFontSize returns the Cupertino chip font size.

func (ChipPainter) ChipMinWidth added in v0.1.37

func (ChipPainter) ChipMinWidth() float32

ChipMinWidth returns the Cupertino minimum chip width.

func (ChipPainter) ChipPadding added in v0.1.37

func (ChipPainter) ChipPadding() float32

ChipPadding returns the Cupertino chip horizontal padding.

func (ChipPainter) ChipRadius added in v0.1.37

func (ChipPainter) ChipRadius() float32

ChipRadius returns the Cupertino chip corner radius.

func (ChipPainter) PaintChip added in v0.1.35

func (p ChipPainter) PaintChip(canvas widget.Canvas, state chip.PaintState)

PaintChip renders a chip according to Apple HIG specifications. It resolves Cupertino color tokens into a chip.ChipColorScheme and delegates to chip.DefaultPainter for consistent rendering across design systems.

type ColorScheme

type ColorScheme struct {
	// Accent is the primary tint color (default: System Blue #007AFF).
	Accent widget.Color

	// OnAccent is the text/icon color on accent backgrounds.
	OnAccent widget.Color

	// Label is the primary text color.
	Label widget.Color

	// SecondaryLabel is the color for secondary text.
	SecondaryLabel widget.Color

	// TertiaryLabel is the color for tertiary text (placeholders).
	TertiaryLabel widget.Color

	// QuaternaryLabel is the color for quaternary text (disabled).
	QuaternaryLabel widget.Color

	// SystemBackground is the primary background color.
	SystemBackground widget.Color

	// SecondarySystemBackground is the grouped/secondary background.
	SecondarySystemBackground widget.Color

	// TertiarySystemBackground is the elevated/tertiary background.
	TertiarySystemBackground widget.Color

	// Separator is the color for thin separators.
	Separator widget.Color

	// OpaqueSeparator is the color for opaque separators.
	OpaqueSeparator widget.Color

	// SystemFill is the color for thin overlays on interactive elements.
	SystemFill widget.Color

	// SecondarySystemFill is the color for medium-thick overlays.
	SecondarySystemFill widget.Color

	// TertiarySystemFill is the color for thick overlays.
	TertiarySystemFill widget.Color

	// SystemRed is the destructive action color.
	SystemRed widget.Color

	// SystemGreen is the success/confirmation color.
	SystemGreen widget.Color

	// SystemOrange is the warning color.
	SystemOrange widget.Color
}

ColorScheme holds the Apple HIG color roles for the Cupertino theme.

Apple uses a set of system-defined adaptive colors that automatically adjust between light and dark modes. This struct provides both semantic colors and the full set of system colors.

type DialogPainter

type DialogPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

DialogPainter renders dialogs using Apple HIG design tokens. Cupertino dialogs follow the iOS alert/sheet style: rounded corners, grouped background, centered title, and stacked or horizontal action buttons.

If Theme is nil, DialogPainter falls back to the default system blue palette.

func (DialogPainter) DialogMaxWidth added in v0.1.37

func (DialogPainter) DialogMaxWidth() float32

DialogMaxWidth returns the Cupertino default maximum dialog width.

func (DialogPainter) DialogPadding added in v0.1.37

func (DialogPainter) DialogPadding() float32

DialogPadding returns the Cupertino dialog padding.

func (DialogPainter) DialogTitleHeight added in v0.1.37

func (DialogPainter) DialogTitleHeight() float32

DialogTitleHeight returns the Cupertino dialog title height.

func (DialogPainter) PaintDialog

func (p DialogPainter) PaintDialog(canvas widget.Canvas, ps dialog.PaintState)

PaintDialog renders a dialog according to Apple HIG specifications.

type DropdownPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

DropdownPainter renders dropdowns using Apple HIG design tokens. Cupertino dropdowns use rounded popover menus with subtle shadows and a chevron indicator following iOS picker conventions.

If Theme is nil, DropdownPainter falls back to the default system blue palette.

func (p DropdownPainter) PaintMenu(canvas widget.Canvas, st *dropdown.MenuPaintState)

PaintMenu renders a dropdown menu according to Apple HIG specifications.

func (p DropdownPainter) PaintTrigger(canvas widget.Canvas, st *dropdown.TriggerPaintState)

PaintTrigger renders a dropdown trigger according to Apple HIG specifications.

type Option

type Option func(*themeConfig)

Option configures a Cupertino theme.

func WithAccentColor

func WithAccentColor(accent widget.Color) Option

WithAccentColor sets the accent (tint) color for the theme. Default is Apple System Blue (#007AFF).

type RadioPainter

type RadioPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

RadioPainter renders radio items using Apple HIG design tokens. Cupertino radio buttons use filled circles with accent-colored selection.

If Theme is nil, RadioPainter falls back to the default system blue palette.

func (RadioPainter) PaintRadio

func (p RadioPainter) PaintRadio(canvas widget.Canvas, state radio.PaintState)

PaintRadio renders a radio item according to Apple HIG specifications.

func (RadioPainter) RadioCircleRadius added in v0.1.37

func (RadioPainter) RadioCircleRadius() float32

RadioCircleRadius returns the Cupertino outer circle radius.

func (RadioPainter) RadioFontSize added in v0.1.37

func (RadioPainter) RadioFontSize() float32

RadioFontSize returns the Cupertino label font size.

func (RadioPainter) RadioItemPadding added in v0.1.37

func (RadioPainter) RadioItemPadding() float32

RadioItemPadding returns the Cupertino radio item padding.

func (RadioPainter) RadioLabelGap added in v0.1.37

func (RadioPainter) RadioLabelGap() float32

RadioLabelGap returns the Cupertino gap between circle and label.

type ScrollbarPainter

type ScrollbarPainter struct {
	Theme *Theme // nil uses default fallback
}

ScrollbarPainter renders scrollbars using Apple HIG design tokens. Cupertino scrollbars are very thin (3px), use rounded ends, and appear only during scrolling with a fade-out effect. They overlay content rather than taking up layout space.

If Theme is nil, ScrollbarPainter falls back to the default Cupertino palette.

func (ScrollbarPainter) PaintScrollbar

func (p ScrollbarPainter) PaintScrollbar(canvas widget.Canvas, ps scrollview.PaintState)

PaintScrollbar renders thin Cupertino-style scrollbars.

type SliderPainter

type SliderPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

SliderPainter renders sliders using Apple HIG design tokens. Cupertino sliders use a thin track with accent-colored active fill and a white thumb with a subtle shadow, following iOS slider conventions.

If Theme is nil, SliderPainter falls back to the default system blue palette.

func (SliderPainter) PaintSlider

func (p SliderPainter) PaintSlider(canvas widget.Canvas, ps slider.PaintState)

PaintSlider renders a slider according to Apple HIG specifications.

func (SliderPainter) SliderThumbRadius added in v0.1.37

func (SliderPainter) SliderThumbRadius() float32

SliderThumbRadius returns the Cupertino thumb radius.

func (SliderPainter) SliderTrackHeight added in v0.1.37

func (SliderPainter) SliderTrackHeight() float32

SliderTrackHeight returns the Cupertino track height.

type TabViewPainter

type TabViewPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

TabViewPainter renders tab bars as iOS-style segmented controls. Instead of a traditional tab bar with an underline indicator, Cupertino uses a pill-shaped segmented control where the selected segment has a raised white background.

If Theme is nil, TabViewPainter falls back to the default system blue palette.

func (TabViewPainter) PaintTabBar

func (p TabViewPainter) PaintTabBar(canvas widget.Canvas, ps tabview.PaintState)

PaintTabBar renders a segmented control according to Apple HIG specifications.

type TextFieldPainter

type TextFieldPainter struct {
	Theme *Theme // nil uses default system blue fallback
}

TextFieldPainter renders text fields using Apple HIG design tokens. Cupertino text fields use a rounded rectangle with a light background and subtle border, following iOS text field conventions.

TextFieldPainter implements textfield.LayoutMetrics to provide Cupertino spatial metrics (15px font, 12/10px padding, 2px cursor) used by the widget to compute pre-computed PaintState fields.

If Theme is nil, TextFieldPainter falls back to the default system blue palette.

func (TextFieldPainter) ContentPadding added in v0.1.37

func (TextFieldPainter) ContentPadding() (float32, float32)

ContentPadding returns the Cupertino horizontal and vertical padding.

func (TextFieldPainter) PaintTextField

func (p TextFieldPainter) PaintTextField(canvas widget.Canvas, st *textfield.PaintState)

PaintTextField renders a text field according to Apple HIG specifications. Cursor and selection positions come from pre-computed PaintState fields.

func (TextFieldPainter) TextFieldCornerRadius added in v0.1.37

func (TextFieldPainter) TextFieldCornerRadius() float32

TextFieldCornerRadius returns the Cupertino corner radius.

func (TextFieldPainter) TextFieldCursorWidth added in v0.1.37

func (TextFieldPainter) TextFieldCursorWidth() float32

TextFieldCursorWidth returns the Cupertino cursor width.

func (TextFieldPainter) TextFieldFontSize added in v0.1.37

func (TextFieldPainter) TextFieldFontSize() float32

TextFieldFontSize returns the Cupertino font size.

type Theme

type Theme struct {
	// Colors holds the Cupertino color scheme.
	Colors ColorScheme

	// Radius is the default corner radius for interactive elements (8-12px).
	Radius float32
	// contains filtered or unexported fields
}

Theme provides Apple Human Interface Guidelines (HIG) design tokens.

A Theme contains the complete set of design tokens needed to style a Cupertino-style application: colors, corner radius, and font size. It can be generated with customizable accent color using NewTheme.

Create a theme with default system blue:

theme := cupertino.NewTheme()
accent := theme.Colors.Accent

Create a dark theme:

darkTheme := cupertino.NewDarkTheme()

Customize accent color:

theme := cupertino.NewTheme(cupertino.WithAccentColor(widget.Hex(0x34C759)))

func NewDarkTheme

func NewDarkTheme(opts ...Option) *Theme

NewDarkTheme creates a Cupertino dark theme.

By default it uses Apple System Blue (#007AFF) as the accent color. Use WithAccentColor to customize.

func NewTheme

func NewTheme(opts ...Option) *Theme

NewTheme creates a Cupertino light theme.

By default it uses Apple System Blue (#007AFF) as the accent color. Use WithAccentColor to customize.

func (*Theme) IsDark

func (t *Theme) IsDark() bool

IsDark returns true if this theme uses a dark color scheme.

func (*Theme) OnSurface

func (t *Theme) OnSurface() widget.Color

OnSurface returns the default text/icon color for surface backgrounds.

This satisfies the widget.ThemeProvider interface and returns the Label color from the theme's color scheme.

Jump to

Keyboard shortcuts

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