プロジェクト
GitHubで見る
kaisermann/svelte-css-vars
概要
:sparkles: Ever wanted to have reactive css variables in svelte? What if I told you there's a way?
Web・アプリ開発計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルsvelte-css-vars
Ever wanted to have reactive css variables in svelte? What if I told you there's a way?
svelte-css-vars exposes a svelte action which receives an object of properties that should be treated as css custom properties. By defining this object inside a $:{} reactive block, svelte-css-vars can update those css properties on the fly whenever some of its values change.
Usage
import cssVars from 'svelte-css-vars';
After importing the module, just define the reactive object of your custom properties:
let some_state_variable = true;
$: styleVars = {
titleColor: some_state_variable ? 'red' : 'blue',
};
And then use the action, passing the object, on the desired element:
<style>
div {
color: var(--titleColor);
}
</style>
<div use:cssVars="{styleVars}">
<!-- anything here will have access to var(--titleColor) -->
</div>
Example
関連プロジェクトを探す
読み込み中…
