Enter a search term above to see results...
On This Page
Component Utility Functions
@semantic-ui/component
includes a few additional helpers in its exports which are used internally and may prove useful for some advanced use cases.
Import
Styles
adoptStylesheet
Adopts a stylesheet into an element’s adoptedStyleSheets. Each stylesheet is only added once, tracked by a hash of its content.
Parameters
Name | Type | Required | Description |
---|---|---|---|
css | string | Yes | CSS to be adopted |
adoptedElement | Element | No | Element to adopt styles into. Defaults to document |
options | Object | No | Configuration options |
Options Object
Name | Type | Default | Description |
---|---|---|---|
scopeSelector | string | undefined | Selector to scope styles to |
Example
scopeStyles
Scopes CSS rules to a specific selector, handling various CSS rule types including media queries, supports rules, and layer statements.
Parameters
Name | Type | Required | Description |
---|---|---|---|
css | string | Yes | CSS content to be scoped |
scopeSelector | string | Yes | Selector to scope styles to |
Returns
The scoped CSS string.
Example
extractCSS
Extracts all CSS rules that match a specific tag name from document stylesheets. Creates a new stylesheet containing only matching rules.
Parameters
Name | Type | Required | Description |
---|---|---|---|
tagName | string | Yes | Tag name to extract CSS for |
Returns
A new CSSStyleSheet containing matching rules.
Example
Properties
adjustPropertyFromAttribute
Synchronizes component properties when attributes change, handling Semantic UI’s attribute dialects and spec-based property mapping.
Parameters
Name | Type | Required | Description |
---|---|---|---|
el | Element | Yes | Web component element instance |
attribute | string | Yes | Attribute name that changed |
attributeValue | any | Yes | New value of the attribute |
properties | Object | No | Component property definitions |
componentSpec | Object | No | Component specification object |