添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
padding-inline: var(--size-1); border-width: var(--border-size-1); border-color: var(--yellow-6); color: var(--yellow-2); border-radius: var(--radius-round); @nest [data-theme="light"] & { border-color: var(--orange-2); color: var(--orange-6); flex-basis: var(--size-content-2); gap: var(--size-5) var(--size-8); align-items: flex-start; @nest [data-theme="light"] & { stroke: var(--indigo-9); @nest a:hover & { stroke: var(--indigo-8); } gap: var(--size-2); font-size: var(--font-size-fluid-1); font-weight: var(--font-weight-2); padding-inline-start: 0; /* optional imports that use the props */ @import "https://unpkg.com/open-props/normalize.min.css"; @import "https://unpkg.com/open-props/buttons.min.css"; /* just dark or light themes */ @import "https://unpkg.com/open-props/normalize.dark.min.css"; @import "https://unpkg.com/open-props/buttons.dark.min.css"; @import "https://unpkg.com/open-props/normalize.light.min.css"; @import "https://unpkg.com/open-props/buttons.light.min.css"; /* individual imports */ @import "https://unpkg.com/open-props/indigo.min.css"; @import "https://unpkg.com/open-props/indigo-hsl.min.css"; @import "https://unpkg.com/open-props/easings.min.css"; @import "https://unpkg.com/open-props/animations.min.css"; @import "https://unpkg.com/open-props/sizes.min.css"; @import "https://unpkg.com/open-props/gradients.min.css"; /* see PropPacks for the full list */ // optional imports that use the props import 'https://unpkg.com/open-props/normalize.min.css'; import 'https://unpkg.com/open-props/buttons.min.css'; // just go dark themed or light themed import 'https://unpkg.com/open-props/normalize.dark.min.css'; import 'https://unpkg.com/open-props/buttons.dark.min.css'; import 'https://unpkg.com/open-props/normalize.light.min.css'; import 'https://unpkg.com/open-props/buttons.light.min.css'; // individual imports import 'https://unpkg.com/open-props/indigo.min.css'; import 'https://unpkg.com/open-props/indigo-hsl.min.css'; import 'https://unpkg.com/open-props/easings.min.css'; import 'https://unpkg.com/open-props/animations.min.css'; import 'https://unpkg.com/open-props/sizes.min.css'; import 'https://unpkg.com/open-props/gradients.min.css'; // see PropPacks for the full list @import "https://unpkg.com/open-props/src/index.css"; /* optional imports that use the props */ @import "https://unpkg.com/open-props/src/extra/normalize.css"; @import "https://unpkg.com/open-props/src/extra/buttons.css"; /* individual imports */ @import "https://unpkg.com/open-props/src/indigo.min.css"; @import "https://unpkg.com/open-props/src/indigo-hsl.min.css"; @import "https://unpkg.com/open-props/src/easings.min.css"; @import "https://unpkg.com/open-props/src/animations.min.css"; @import "https://unpkg.com/open-props/src/sizes.min.css"; @import "https://unpkg.com/open-props/src/gradients.min.css"; /* see PropPacks for the full list */

Community created setup instructions .

https://unpkg.com/open-props/open-props.figma-tokens.json https://unpkg.com/open-props/open-props.figma-tokens.sync.json import "open-props/style-dictionary-tokens" // or import "open-props/open-props.style-dictionary-tokens.json" https://unpkg.com/open-props/open-props.style-dictionary-tokens.json /* the props */ @import "open-props/shadow/style"; @import "open-props/open-props.shadow.min.css"; /* individual imports */ @import "open-props/shadow/indigo"; @import "open-props/shadow/indigo-hsl"; @import "open-props/shadow/easings"; @import "open-props/shadow/animations"; @import "open-props/shadow/sizes"; @import "open-props/shadow/gradients"; /* see PropPacks for the full list */ @import "https://unpkg.com/open-props/open-props.shadow.min.css"; /* individual imports */ @import "https://unpkg.com/open-props/indigo.shadow.min.css"; @import "https://unpkg.com/open-props/indigo.shadow-hsl.min.css"; @import "https://unpkg.com/open-props/easings.shadow.min.css"; @import "https://unpkg.com/open-props/animations.shadow.min.css"; @import "https://unpkg.com/open-props/sizes.shadow.min.css"; @import "https://unpkg.com/open-props/gradients.shadow.min.css"; /* see PropPacks for the full list */ /* optional imports that use the props */ @import "open-props/normalize"; @import "open-props/buttons"; /* just light or dark themes */ @import "open-props/normalize/dark"; @import "open-props/buttons/dark"; @import "open-props/normalize/light"; @import "open-props/buttons/light"; /* individual imports */ @import "open-props/indigo"; @import "open-props/easings"; @import "open-props/animations"; @import "open-props/sizes"; @import "open-props/gradients"; /* see PropPacks for the full list */ /* optional imports that use the props */ @import "open-props/normalize.min.css"; @import "open-props/buttons.min.css"; /* individual imports */ @import "open-props/indigo.min.css"; @import "open-props/easings.min.css"; @import "open-props/animations.min.css"; @import "open-props/sizes.min.css"; @import "open-props/gradients.min.css"; /* see PropPacks for the full list */ /* optional imports that use the props */ @import "open-props/postcss/normalize"; @import "open-props/postcss/buttons"; /* individual imports */ @import "open-props/postcss/indigo"; @import "open-props/postcss/easings"; @import "open-props/postcss/animations"; @import "open-props/postcss/sizes"; @import "open-props/postcss/gradients"; /* see PropPacks for the full list */ /* optional imports that use the props */ @import "open-props/postcss/extra/normalize.css"; @import "open-props/postcss/extra/buttons.css"; /* individual imports */ @import "open-props/postcss/indigo.min.css"; @import "open-props/postcss/easings.min.css"; @import "open-props/postcss/animations.min.css"; @import "open-props/postcss/sizes.min.css"; @import "open-props/postcss/gradients.min.css"; /* see PropPacks for the full list */ // index.js loading JS object import OpenProps from 'open-props'; // module import OpenProps from 'open-props/src'; // unbundled ES module import Colors from 'open-props/src/colors'; // object notation access is special to OpenProps console.info(OpenProps.size1); console.info(OpenProps['--size-1']); console.info(Colors['--indigo-5']); // postcss.config.js const postcssJitProps = require('postcss-jit-props'); const OpenProps = require('open-props'); module.exports = { plugins: [ postcssJitProps(OpenProps),
Props from CSS
// postcss.config.js const postcssJitProps = require('postcss-jit-props'); const path = require('path'); module.exports = { plugins: [ postcssJitProps({ files: [ path.resolve(__dirname, 'node_modules/open-props/open-props.min.css'), // build src files npm run gen:shadowdom // src files with `:host` instead of `html` npm run gen:nowhere // src files without `:where()` npm run gen:prefixed // each prop prefixed with `op`, like `--op-font-size-1` // full custom! pass args with node to the props.js script node props.js 'ns' true ':root' 'my' // arg1: default '', is a custom namespace, props will be --ns-gray-1 // arg2: default false, indicates wrapping in :where() or not // arg3: default '', set a custom selector like :scope, .my-class, etc // arg4: default '', set a file prefix, files will be my.props.easing.css, etc
Build Locally
npm run gen:op // runs through `src/` js files and creates the PostCSS files in `src/` npm run gen:shadowdom // runs through `src/` js files and creates the PostCSS files in `src/` npm run build // does both gen:op and gen:shadowdom npm run bundle // creates all the various minified bundles of props npm run lib:js // builds the JS modules for NPM VScode has an intellisense feature which you can tap into, by passing the path to the node_modules folder where open-props is installed In your VScode environment, navigate to the extensions marketplace, and install this CSS Var Complete extension When the extension is installed, you'll have to add open-prop's css file path to a .vscode/settings.json file. Take a look at an illustration below // .vscode/settings.json file "cssvar.files": [ "./node_modules/open-props/open-props.min.css", // if you have an alternative path to where your styles are located // you can add it in this array of files "assets/styles/variables.css" // Do not ignore node_modules css files, which is ignored by default "cssvar.ignore": [], // add support for autocomplete in JS or JS like files "cssvar.extensions": [ "css", "postcss", "jsx", "tsx" Check details on settings and it's defaults  in the repo There are number of ways with which the autocomplete engine of Sublime Text can be extended. You can decide to use the completion files , snippets or plugins . An approach that is less strenuous is the "completion file" approach. Here, all you'd be required to do is point the `scope` keyword in the .sublime-completions file to the open-props classes in the node_modules folder like so: // .sublime-completions file "scope": "./node_modules/open-props/open-props.min.css", "completions": [ // here you'll add the classes you want autocomplete for.
  • You can also add an alternative path to your variables, if you have one — in the completions file, like so:
  • // .sublime-completions file "scope": "path/to/your/variables",
  • Another approach for enabling autocomplete would be to open the settings json file of Sublime Text via Preferences > Settings , then you'll modify the file to include the snippet below — replacing "source" with the path to your variables. "auto-complete-selector": "source, text" You can learn more about the completion process in Sublime Text here. background-color: var(--blue-0); border: 1px solid var(--blue-1); text-shadow: 0 1px 0 var(--blue-2); &:hover { background-color: var(--blue-1);
    Light & Dark Example
    html { --text-1: var(--gray-9); --text-2: var(--gray-7); @media (--OSdark) { --text-1: var(--gray-1); --text-2: var(--gray-2);
    Modify Opacity Example
    /* additional import required */ /* @import "open-props/gray-hsl"; */ @import "open-props/colors-hsl"; .backdrop { background-color: hsl(var(--gray-9-hsl) / 30%);

    1) Color theming

    Low numbers are light and high numbers are dark. See how the Open Props normalize.css implements light and dark modes.

    See it live: auto, light, dark, dim and purple themes demonstrated with Open Props!

    --surface-1-light: var(--gray-0); --surface-2-light: var(--gray-1); --surface-3-light: var(--gray-2); --surface-4-light: var(--gray-3); html { --brand-dark: var(--orange-3); --text-1-dark: var(--gray-3); --text-2-dark: var(--gray-5); --surface-1-dark: var(--gray-12); --surface-2-dark: var(--gray-11); --surface-3-dark: var(--gray-10); --surface-4-dark: var(--gray-9); html { --brand-dim: var(--orange-4); --text-1-dim: var(--gray-3); --text-2-dim: var(--gray-4); --surface-1-dim: var(--gray-8); --surface-2-dim: var(--gray-7); --surface-3-dim: var(--gray-6); --surface-4-dim: var(--gray-5);
    Purple
    html { --brand-purple: var(--purple-5); --text-1-purple: var(--purple-9); --text-2-purple: var(--purple-7); --surface-1-purple: var(--purple-0); --surface-2-purple: var(--purple-1); --surface-3-purple: var(--purple-2); --surface-4-purple: var(--purple-3);

    2) Creating adaptive color schemes

    It's not ideal for components to reference individual light or dark theme colors. Instead, you should prefer to use these individual variables to build a set of theme-agnostic aliases. This allows you to reference a custom property without worrying about its underlying value, which will dynamically adapt to the current context's theme.

    --surface-1: var(--surface-1-light); --surface-2: var(--surface-2-light); --surface-3: var(--surface-3-light); --surface-4: var(--surface-4-light);
    Prefers Dark
    @media (prefers-color-scheme: dark) { :root { --brand: var(--brand-dark); --text-1: var(--text-1-dark); --text-2: var(--text-2-dark); --surface-1: var(--surface-1-dark); --surface-2: var(--surface-2-dark); --surface-3: var(--surface-3-dark); --surface-4: var(--surface-4-dark);
    Prefers Dim
    @media (prefers-contrast: less) { :root { --brand: var(--brand-dim); --text-1: var(--text-1-dim); --text-2: var(--text-2-dim); --surface-1: var(--surface-1-dim); --surface-2: var(--surface-2-dim); --surface-3: var(--surface-3-dim); --surface-4: var(--surface-4-dim); --surface-1: var(--surface-1-purple); --surface-2: var(--surface-2-purple); --surface-3: var(--surface-3-purple); --surface-4: var(--surface-4-purple);

    Gradients

    Open Props includes 30 handcrafted gradients. Linear gradient direction can be changed with a custom property mixin.

    Don't miss the noise props inspired by grainy-gradients .

    background: var(--gradient-1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; .noise-noise-noise { /* stack grain with a gradient */ background-image: var(--gradient-3), var(--noise-3); /* force colors and noise to collide */ filter: var(--noise-filter-3); /* fit noise image to element */ background-size: cover; line-height: var(--font-lineheight-1); font-size: var(--font-size-fluid-3); font-weight: var(--font-weight-9); font-family: var(--font-sans);

    Font Families

    --font-sans: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif; --font-serif: ui-serif, serif; --font-mono: Dank Mono, Operator Mono, Inconsolata, Fira Mono, ui-monospace, SF Mono, Monaco, Droid Sans Mono, Source Code Pro, monospace; --font-sans A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 + = ! @ # % $ % ^ & --font-serif A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 + = ! @ # % $ % ^ & --font-mono A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 + = ! @ # % $ % ^ & --font-letterspacing-0: -.05em; --font-letterspacing-1: .025em; --font-letterspacing-2: .050em; --font-letterspacing-3: .075em; --font-letterspacing-4: .150em; --font-letterspacing-5: .500em; --font-letterspacing-6: .750em; --font-letterspacing-7: 1em;
    Letter Spacing
    Almost before you knew it, we'd touched ground. var(--font-size-0) Almost before you knew it, we'd touched ground. var(--font-size-1) Almost before you knew it, we'd touched ground. var(--font-size-2) Almost before you knew it, we'd touched ground. var(--font-size-3) Almost before you knew it, we'd touched ground. var(--font-size-4) Almost before you knew it, we'd touched ground. var(--font-size-5) Almost before you knew it, we'd touched ground. var(--font-size-6) Almost before you knew it, we'd touched ground. var(--font-size-7) Almost before you knew it, we'd touched ground. var(--font-size-8) Almost before you knew it, we'd touched ground. --font-size-fluid-0: clamp(.75rem, 1.5vw, 1rem); --font-size-fluid-1: clamp(1rem, 2vw, 1.5rem); --font-size-fluid-2: clamp(1.5rem, 3vw, 2.5rem); --font-size-fluid-3: clamp(2rem, 4vw, 3.5rem); var(--font-size-fluid-0) Almost before you knew it, we'd touched ground. var(--font-size-fluid-1) Almost before you knew it, we'd touched ground. var(--font-size-fluid-2) Almost before you knew it, we'd touched ground. var(--font-size-fluid-3) Almost before you knew it, we'd touched ground. /* will be removed in v2 */ --ease-elastic-{1-5} /* deprecated; equal to elastic-out */ --ease-squish-{1-5} /* deprecated; equal to elastic-in-out */ var(--animation-fade-out) forwards, var(--animation-slide-out-down); animation-timing-function: var(--ease-elastic-in-out-3); animation-duration: 1s; var(--animation-scale-down), var(--animation-fade-out); animation-timing-function: var(--ease-elastic-in-out-4);

    Sizes

    Sizes use relative units by default with rem but static, px -based units are also available. 0 s are unsafe but common negative values, while 1-N are safe.

    The Props
    --size-{000-15} --size-px-{000-15} --size-fluid-{1-10} --size-content-{1-3} --size-header-{1-3} --size-relative-{000-15} --size-fluid-1: clamp(.5rem, 1vw, 1rem); --size-fluid-2: clamp(1rem, 2vw, 1.5rem); --size-fluid-3: clamp(1.5rem, 3vw, 2rem); --size-fluid-4: clamp(2rem, 4vw, 3rem); --size-fluid-5: clamp(4rem, 5vw, 5rem); --size-fluid-6: clamp(5rem, 7vw, 7.5rem); --size-fluid-7: clamp(7.5rem, 10vw, 10rem); --size-fluid-8: clamp(10rem, 20vw, 15rem); --size-fluid-9: clamp(15rem, 30vw, 20rem); --size-fluid-10: clamp(20rem, 40vw, 30rem);

    Carrot cake gummi bears sweet caramels cotton candy topping.

    Carrot cake gummi bears sweet caramels cotton candy topping. Jelly candy apple pie gingerbread tootsie roll chupa chups.

    Carrot cake gummi bears sweet caramels cotton candy topping. Jelly candy apple pie gingerbread tootsie roll chupa chups. Gummi bears lollipop apple pie pudding tart cake jelly. Soufflé lollipop jelly-o chocolate bar icing bonbon.

    Carrot cake gummi bears sweet caramel candy.
    Carrot cake gummi bears sweet caramels cotton candy topping.
    Carrot cake gummi bears sweet caramels cotton candy topping. Jelly candy apple pie gingerbread tootsie roll chupa chups.
    /* no radius when fullscreen */ border-radius: var(--radius-conditional-3); border: var(--border-size-1) solid var(--gray-1); .circle { inline-size: var(--size-5); aspect-ratio: var(--ratio-square); border-radius: var(--radius-round); .drawn { inline-size: var(--size-14); border: var(--brown-12) var(--border-size-4) solid; border-radius: var(--radius-drawn-1); --{xxs,xs,sm,md,lg,xl,xxl}-only --{xxs,xs,sm,md,lg,xl,xxl}-n-above --{xxs,xs,sm,md,lg,xl,xxl}-n-below --{xxs,xs,sm,md,lg}-phone @custom-media --portrait (orientation: portrait); @custom-media --landscape (orientation: landscape); @custom-media --md-only (480px <= width < 768px); @custom-media --md-n-above (width >= 768px); @custom-media --md-n-below (width < 768px); @custom-media --md-phone (--md-only) and (--portrait); @custom-media --xxl-only (1440px <= width < 1920px); @custom-media --xxl-n-above (width >= 1920px); @custom-media --xxl-n-below (width < 1920px); @custom-media --touch (hover: none) and (pointer: coarse); @custom-media --stylus (hover: none) and (pointer: fine); @custom-media --pointer (hover) and (pointer: coarse); @custom-media --mouse (hover) and (pointer: fine); @custom-media --HDcolor (dynamic-range: high) or (color-gamut: p3); @custom-media --OSdark (prefers-color-scheme: dark); @custom-media --OSlight (prefers-color-scheme: light); @custom-media --motionOK (prefers-reduced-motion: no-preference); @custom-media --motionNotOK (prefers-reduced-motion: reduce); @custom-media --invertedColors (inverted-colors: inverted); @custom-media --forcedColors (forced-colors: active); @custom-media --highContrast (prefers-contrast: more); @custom-media --lowContrast (prefers-contrast: less); @custom-media --opacityOK (prefers-reduced-transparency: no-preference); @custom-media --opacityNotOK (prefers-reduced-transparency: reduce); @custom-media --useDataOK (prefers-reduced-data: no-preference); @custom-media --useDataNotOK (prefers-reduced-data: reduce); /* NPM */ @import "open-props/masks/edges"; @import "open-props/src/props.masks.edges.css"; @import "open-props/masks.edges.min.css"; /* CDN */ @import "https://unpkg.com/open-props/masks.edges.min.css";
    Scoops
    Right
    Bottom
    Vertical
    Horizontal
    --mask-edge-scoop-{top,right,bottom,left,vertical,horizontal} .mask-usage { -webkit-mask: var(--mask-edge-scoop-top); /* NPM */ @import "open-props/masks/corner-cuts"; @import "open-props/src/props.masks.corner-cuts.css"; @import "open-props/masks.corner-cuts.min.css"; /* CDN */ @import "https://unpkg.com/open-props/masks.corner-cuts.min.css";
    Circles
    --mask-corner-cut-circles-{1,2,3} .mask-usage { -webkit-mask: var(--mask-corner-cut-circles-2);
  •