Component Format
Style
CSS inside a <style>
block will be scoped to that component.
This works by adding a class to affected elements, which is based on a hash of the component styles (e.g. svelte-123xyz
).
To apply styles to a selector globally, use the :global(...)
modifier.
If you want to make @keyframes that are accessible globally, you need to prepend your keyframe names with -global-
.
The -global-
part will be removed when compiled, and the keyframe then be referenced using just my-animation-name
elsewhere in your code.
There should only be 1 top-level <style>
tag per component.
However, it is possible to have <style>
tag nested inside other elements or logic blocks.
In that case, the <style>
tag will be inserted as-is into the DOM, no scoping or processing will be done on the <style>
tag.