primevue-mirror/doc/theming/styled/ScopedTokensDoc.vue

98 lines
2.8 KiB
Vue
Raw Normal View History

2024-04-01 12:55:29 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Design tokens can be scoped to a certain component using CSS variables. In this example, first switch uses the global tokens whereas second one overrides the global with its own tokens.</p>
</DocSectionText>
<div class="card flex justify-content-center gap-3">
2024-04-18 14:22:30 +00:00
<ToggleSwitch v-model="checked1" />
<ToggleSwitch v-model="checked2" :dt="amberSwitch" />
2024-04-01 12:55:29 +00:00
</div>
<DocSectionCode :code="code1" importCode hideToggleCode hideStackBlitz />
</template>
<script>
export default {
data() {
return {
checked1: true,
checked2: true,
amberSwitch: {
handle: {
borderRadius: '4px'
},
colorScheme: {
light: {
root: {
checkedBackground: '{amber.500}',
checkedHoverBackground: '{amber.600}',
borderRadius: '4px'
},
handle: {
2024-04-01 13:15:14 +00:00
checkedBackground: '{amber.50}',
checkedHoverBackground: '{amber.100}'
2024-04-01 12:55:29 +00:00
}
},
dark: {
root: {
checkedBackground: '{amber.400}',
checkedHoverBackground: '{amber.300}',
borderRadius: '4px'
},
handle: {
2024-04-01 13:15:14 +00:00
checkedBackground: '{amber.900}',
checkedHoverBackground: '{amber.800}'
2024-04-01 12:55:29 +00:00
}
}
}
},
code1: {
basic: `
<template>
<div>
2024-04-18 14:22:30 +00:00
<ToggleSwitch v-model="checked1" />
<ToggleSwitch v-model="checked2" :dt="amberSwitch" />
2024-04-01 12:55:29 +00:00
</div>
</template>
<script setup>
import { ref } from 'vue';
const checked1 = ref(true);
const checked2 = ref(true);
const amberSwitch = ref({
handle: {
borderRadius: '4px'
},
colorScheme: {
light: {
root: {
checkedBackground: '{amber.500}',
checkedHoverBackground: '{amber.600}',
borderRadius: '4px'
},
handle: {
2024-04-01 13:15:14 +00:00
checkedBackground: '{amber.50}',
checkedHoverBackground: '{amber.100}'
2024-04-01 12:55:29 +00:00
}
},
dark: {
root: {
checkedBackground: '{amber.400}',
checkedHoverBackground: '{amber.300}',
borderRadius: '4px'
},
handle: {
2024-04-01 13:15:14 +00:00
checkedBackground: '{amber.900}',
checkedHoverBackground: '{amber.800}'
2024-04-01 12:55:29 +00:00
}
}
}
});
<\/script>
`
}
};
}
};
</script>