1.2.7 • Published 1 year ago

unocss-preset-scalpel v1.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Installation

npm i unocss-preset-scalpel unocss --save-dev # with npm
yarn add unocss-preset-scalpel unocss -D # with yarn
pnpm add unocss-preset-scalpel unocss -D # with pnpm

Usage

import { defineConfig } from 'unocss'
import { presetScalpel } from 'unocss-preset-scalpel'

export default defineConfig({
  presets: [
    presetScalpel({
      // config
    }),
  ],
})

why Scalpel

Atomic css should scalpel-like precision

use any colors and any unit with number

why we need memorize rules? like tailwind css w-1{width: 0.25rem;}

why 1 mean 0.25 if need 0.25rem just write it ! like w-0.25rem

write atomic css like native css width-0.25rem

this preset usually write like native css, use - concat key value like display-flex

of course we has some shortcuts

shortcuts

native css is sooooo long this preset define some shortcuts

shortcutmeandesc
mmargin
ppadding
wwidth
hheight
ttop
rright
bbottom
lleft
xleft and right
ytop and bottom
m-Minus signnegative number in some value

special unit

there are some special units

unitmeandesc
p%percent eq %
vvariableusually used for px to rem

important

use end with ! className toggle !important

pseudo

use pseudo before any className

like this

pseudo
any-linkblankcheckedcurrent
defaultdefineddisableddrop
emptyenabledfirstfirst-child
first-of-typefullscreenfuturefocus
focus-visiblefocus-withinhosthover
indeterminatein-rangeinvalidactive
last-childlast-of-typeleftlink
local-linkonly-childonly-of-typeoptional
out-of-rangepastplaceholder-shownread-only
read-writerequiredrightroot
targettarget-withinuser-invalidvalid
visitescope
<div class="hover:color-transparent">hover me to transparent</div>

media query

use media query before any className and pseudo

the default media query has sm md lg xl like this

<div class="md@hover:color-transparent">hover me to transparent</div>
<div class="md@color-f00 xl@color-red color-blue"></div>

Configurations

config object like this

// this is preset default value
{
  /**
   * define color name
   */
  colors:{
    red: '#f00',
    white: '#fff',
    black: '#000',
    blue: '#00f',
    yellow: '#ff0',
    transparent: 'transparent',
    // diyColor:'#30336b'
  },
  /**
   * the default unit you can omitted
   * like width-1 mean this unit ⬇
   */
  unit:'px',
  /**
   * write you like mediaQuery
   */
  mediaQueries:{
    sm: 'media (min-width: 640px)',
    md: 'media (min-width: 768px)',
    lg: 'media (min-width: 1024px)',
    xl: 'media (min-width: 1280px)',
    // supportGrid: 'supports (display: grid)'
  },
  // set all css has important
  important:false,
  // ignore some rules like ['flexBasis']
  ignoreRules:[],
  // convert unit v
  vToAny: {
    unit: 'rem', // convert v to rem
    rootValue: 16, // value ÷ this
    unitPrecision: 5,
    minPixelValue: 1,
  },

}

How to use

  • width and height

    support shortcut w h

    ClassProperties
    w-0width:0;
    w-20width:20px;
    width-20width:20px;
    w-0.25vhwidth:0.25vh
    width-333.333pwidth:333.333%
    w-3.1415width:3.1415%
    width-100vwidth:6.25rem
    h-0height:0;
    height-20height:20px;
    h-20height:20px;
    height-0.25vhheight:0.25vh
    h-333.333pheight:333.333%
    height-3.1415height:3.1415%
    h-100vheight:6.25rem
  • min max width and height

    add min- or max- before width or height
    support shortcut w h

    ClassProperties
    min-w-0.25vhmin-width:0.25vh
    min-width-0.25vhmin-width:0.25vh
    max-h-0.25vhmax-height:0.25vh
    max-height-0.25vhmax-height:0.25vh
  • square

    use square set same width and height

    ClassProperties
    square-25width:25px;height:25px;
    square-0.25vhwidth:0.25vh;height:0.25vh
  • margin and padding

    set margin and padding with direction
    this value has negative number
    support shortcut m p m- t r b l x y

    ClassProperties
    m-25margin:25px;
    p-25padding:25px;
    m-m-25margin:-25px;
    p-x-999vhpadding-left:999vh;padding-right:999vh;
    m-l-0.25remmargin-right:0.25rem;
  • border

    set border with direction
    use border or border-w or border-width

    ClassProperties
    border-1border-width:1px
    border-x-3border-left-width:3px;border-right-width:3px;
    border-l-0border-left-width:0;
    border-r-1.25remborder-right-width:1.25rem;
    border-w-2border-width:2px;
    border-width-0border-width:0;
  • border-style

    set border-style
    support shortcut border

    ClassProperties
    border-style-solidborder-style:solid;
    border-dottedborder-style:dotted;

    enum values

    Value
    nonehiddendotted
    dashedsoliddouble
    grooveridgeinset
    outsetinherit-
  • border-radius

    set border-radius any number and unit
    use br or border-radius
    support shortcut t l r b tl lt tr rt bl lb br rb

    ClassProperties
    br-8border-radius:8px;
    border-radius-15%border-radius:15%;
    br-t-50%border-top-left-radius:50%;border-top-right-radius:50%;
    br-l-20border-top-left-radius:20px;border-bottom-left-radius:20px;
    br-bl-3border-bottom-left-radius:3px;
  • circle

    set border-radius 50% is static preset

    ClassProperties
    circleborder-radius:50%;
  • box-sizing

    set box-sizing

    ClassProperties
    box-sizing-content-boxbox-sizing:content-box;
    box-sizing-border-boxbox-sizing:border-box;
  • color

    Amazing! we can use all color by hex and set opacity, and you can define color name!
    has special value transparent
    use 3-digit and 6-digit and 8-digit (rgba) hex just copy from design draft like figma!! just copy it !
    color has some shortcut

    ShortcutDesc
    ccolor
    textcolor
    bgbackground
    border-cborder-color
    borderborder-color
    ClassProperties
    c-redcolor:rgba(255, 0, 0, 1);
    c-transparentcolor:transparent;
    text-f00-25background:rgba(255, 0, 0, 0.25);
    color-#54a0ffcolor:rgba(84, 160, 255, 1);
    bg-#fffc0140background:rgba(255, 252, 1, 0.25);
    background-10ac84background:rgba(16, 172, 132, 1);
    border-000background:rgba(0, 0, 0, 1);
    border-color-000-15background:rgba(0, 0, 0, 0.15);
  • cursor

    set cursor value
    rule is cursor-\<value>

    ClassProperties
    cursor-pointercursor:pointer;
    cursor-no-dropcursor:no-drop;

    enum values

    Value
    autodefaultnone
    context-menuhelppointer
    progresswaitcell
    crosshairtextvertical-text
    aliascopymove
    no-dropnot-allowede-resize
    n-resizene-resizenw-resize
    s-resizese-resizesw-resize
    w-resizeew-resizens-resize
    nesw-resizenwse-resizecol-resize
    row-resizeall-scrollzoom-in
    zoom-outgrabgrabbing
  • display

    set display value
    rule is display-\<value> or d-\<value>

    ClassProperties
    d-tabledisplay:table;
    display-flexdisplay:flex;

    enum values

    Value
    unsetrevertinitial
    inheritlist-itemtable-row
    tablecontentsnone
    flow-rootinline-gridgrid
    inline-flexflexinline-block
    inlineblock
  • flex-basis

    set flex-basis use nonnegative number and unit or native

    ClassProperties
    flex-basis-1flex-basis:1px;
    flex-basis-3.25remflex-basis:3.25rem;
    flex-basis-autoflex-basis:auto;

    enum values

    Value
    initialinheritauto
  • flex-direction

    set flex-direction
    support shortcut flex

    ClassProperties
    flex-direction-rowflex-direction;row;
    flex-direction-row-reverseflex-direction;row-reverse;
    flex-columnflex-direction;column;
    flex-column-reverseflex-direction;column-reverse;

    enum values

    Value
    rowrow-reversecolumncolumn-reverse
  • flex with justify-content and align-items

    set display flex with justify-content with align-items in one className
    rule is flex-\-\

    shortcutdesc
    betweenspace-between
    aroundspace-around
    evenlyspace-evenly

    enum values

    justify valuesalign values
    centerauto
    startcenter
    endend
    flex-startflex-end
    flex-endflex-start
    leftinherit
    rightinitial
    space-betweennormal
    betweenself-end
    space-aroundself-start
    aroundstart
    space-evenlystretch
    evenlyunset
    stretchbaseline
    inherit
    initial
    unset

    | normal

    ClassProperties
    flex-center-centerdisplay:flex;justify-content:center;align-items:center;
    flex-flex-start-flex-enddisplay:flex;justify-content:flex-start;align-items:flex-end;
    flex-between-centerdisplay:flex;justify-content:space-between;align-items:center;
  • align-items

    set align-items enum values look ⬆

    ClassProperties
    align-items-baselinealign-items:baseline;
    align-items-centeralign-items:center;
    align-items-endalign-items:end;
    align-items-flex-startalign-items:flex-start;
  • justify-content

    set justify-content enum values look ⬆

    ClassProperties
    justify-content-leftjustify-content:left;
    justify-content-betweenjustify-content:space-between;
  • flex-num

    set sets how a flex item will grow or shrink to fit the space available in its flex container.
    like flex-\<number> or native value

    ClassProperties
    flex-0flex:0;
    flex-1flex:1;
    flex-999flex:999;
    flex-autoflex:auto;

    support native values

    Value
    nullautonone
  • flex-shrink and flex-grow

    set flex-shrink or flex-grow

    ClassProperties
    flex-shrink-20flex-shrink:20;
    flex-grow-5flex-grow:5;
    flex-shrink-initialflex-shrink:initial;

    support native values

    Value
    initial
    inherit
  • flex-wrap

    set flex-wrap
    support shortcut flex

    ClassProperties
    flex-wrap-wrapflex-wrap:wrap;

    enum values

    Value
    inherit
    initial
    nowrap
    wrap
    wrap-reverse
  • font-size

    set font size
    support shortcut fs

    ClassProperties
    font-size-12flex-wrap:12px;
    font-size-5remflex-wrap:5rem;
    fs-0.22vhflex-wrap:0.22vh;
  • font-weight

    set font weight
    support shortcut fw

    ClassProperties
    font-weight-bolderfont-weight:bolder;
    fw-100font-weight:100;

    enum values

    Value
    100200300
    400500600
    700800000
    boldbolderinherit
    initiallighternormal
    unset
  • gap

    set column-gap and row-gap in one className

    ClassProperties
    gap-0column-gap:0;row-gap:0;
    gap-25.5pcolumn-gap:25.5%;row-gap:25.5%;
    gap-15%column-gap:15%;row-gap:15%;
    gap-normalcolumn-gap:normal;row-gap:normal;

    enum values

    Value
    unset
    initial
    inherit
    normal
  • column-gap

    set column-gap with any number unit or native value support shortcut c-gap

    ClassProperties
    column-gap-normalcolumn-gap:normal;
    c-gap-0.25cmcolumn-gap:0.25cm;
    c-gap-99999column-gap:99999px;

    enum values same gap ⬆️

  • row-gap

    set row-gap with any number unit or native value
    support shortcut r-gap
    support native value is unset initial inherit normal

    ClassProperties
    r-gap-normalrow-gap:normal;
    row-gap-0.25cmrow-gap:0.25cm;
    r-gap-99999row-gap:99999px;

    enum values same gap ⬆️

  • letter-spacing

    set letter spacing use any number and unit
    this value has negative number

    ClassProperties
    letter-spacing-3.1415remletter-spacing:3.1415rem
    letter-spacing-m-3.1415remletter-spacing:-3.1415rem
    letter-spacing-9999pxletter-spacing:9999px
  • line-height

    set line height use nonnegative number and any unit support shortcut lh

    ClassProperties
    lh-0.25remline-height:0.25rem;
    line-height-20line-height:20px;
  • object-fit

    set object file

    ClassProperties
    object-fit-fillobject-fit:fill;
    object-fit-containobject-fit:contain;

    enum values

    Value
    fillcontaincover
    nonescale-downinherit
    initialrevertunset
  • opacity

    set opacity (1 to 100 ) ÷ 100

    ClassProperties
    opacity-20opacity:0.2
    opacity-55opacity:0.55
  • orientation

    set orientation with any number any unit
    this value has negative number use -m
    support shortcut t r b l -m

    ClassProperties
    t-20top:20px;
    bottom-3.14rembottom:3.14rem;
    b-m-3.14rembottom:-3.14rem;
    r-m-60vhright:-60vh;
  • overflow

    set overflow-x or overflow-y

    ClassProperties
    overflow-x-scrolloverflow-x:scroll;
    overflow-y-autooverflow-y:auto;

    enum values

    Value
    hidden
    auto
    visible
    scroll
    inherit
  • position

    set position

    ClassProperties
    position-stickyposition:sticky;
    position-absoluteposition:absolute;
    position-fixedposition:fixed;

    enum values

    Value
    staticrelativesticky
    unsetabsolutefixed
    inheritinitial-
  • text-align

    set text-align support shortcut text

    ClassProperties
    text-centertext-align:center;
    text-align-justifytext-align:justify;

    enum values

    Value
    startendleft
    rightcenterjustify
    match-parent--
  • text-align-last

    set text-align-last support shortcut text-last

    ClassProperties
    text-last-centertext-align-last:center;
    text-align-last-starttext-align-last:start;

    enum values

    Value
    autoleftright
    centerjustifystart
    endinitialinherit
  • text-decoration

    set text-decoration support shortcut text

    ClassProperties
    text-underlinetext-decoration:underline;
    text-decoration-overlinetext-decoration:overline;

    enum values

    Value
    noneunderlineoverline
    line-throughblinkinherit
  • text-ellipsis

    set ellipsis support multiline support shortcut ellipsis

    ClassProperties
    ellipsisoverflow: hidden;text-overflow: ellipsis;white-space: nowrap
    ellipsis-2overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp:2;-webkit-box-orient: vertical;
    text-ellipsis-5overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp:5;-webkit-box-orient: vertical;
  • user-select

    set user-select support shortcut select

    ClassProperties
    select-autoselect:auto;
    select-noneselect:none;

    enum values

    Value
    noneautotext
    allcontainelement
  • visibility

    set visibility

    ClassProperties
    visibility-visiblevisibility:visible;
    visibility-hiddenvisibility:hidden;

    enum values

    Value
    visiblehiddencollapse
    inheritinitialrevert
    unset--
  • word-break

    set word-break

    ClassProperties
    word-break-break-allword-break:break-all;
    word-break-keep-allword-break:keep-all;

    enum values

    Value
    normalbreak-allkeep-all
    break-wordinheritinitial
    unset--
  • z-index

    set z-index with number
    this value has negative number

    ClassProperties
    z-index-0z-index:0;
    z-index-1z-index:1;
    z-index-m-5z-index:-5;
    z-index-99999z-index:99999;
1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.0-beta.2

2 years ago

0.1.0-beta.1

2 years ago

0.0.1-beta.1

2 years ago