a11y/role.go

Functions

Functions

func IsContainer

IsContainer returns true if the role represents an element that contains

other accessible elements, such as dialogs, lists, and tables.

func (r Role) IsContainer() bool {
	return r >= RoleDialog && r <= RoleFeed
}

func IsInteractive

IsInteractive returns true if the role represents an element that accepts

user input, such as buttons, text fields, and sliders.

func (r Role) IsInteractive() bool {
	return r >= RoleButton && r <= RoleColorWell
}

func IsLandmark

IsLandmark returns true if the role represents a navigational landmark region,

such as main content, navigation, or search.

func (r Role) IsLandmark() bool {
	switch r {
	case RoleNavigation, RoleBanner, RoleMain, RoleContentInfo,
		RoleComplementary, RoleRegion, RoleForm, RoleSearch:
		return true
	default:
		return false
	}
}

func String

String returns a human-readable name for the role.

 

The returned string matches the role constant name without the "Role" prefix.

For example, RoleButton returns "Button" and RoleCheckbox returns "Checkbox".

func (r Role) String() string {
	if name, ok := roleNames[r]; ok {
		return name
	}
	return unknownStr
}