npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sanity-plugin-block-styles

v1.0.0

Published

Visual block style controls for Sanity Studio — spacing, borders, backgrounds, typography, and

Readme

sanity-plugin-block-styles

Visual style controls for Sanity Studio. Add spacing, borders, backgrounds, typography, and effects to any schema type through custom inputs.

Studio Block Styles

What it does

Registers a blockStyles object type in your schema with 6 custom input groups:

  • Spacing — padding and margin with a visual box model picker, split into mobile/tablet/desktop breakpoints
  • Border — width, style, and color with inline controls
  • Border Radius — per-corner radius with a link/unlink toggle for uniform values
  • Background — color picker + optional image with size and overlay controls
  • Typography — text alignment, font size, and text color
  • Effects — box shadow presets, opacity slider, and overflow control

Every group has a clear button to reset values. Color fields use an inline picker with swatch preview and hex input.

Installation

npm install sanity-plugin-block-styles

Setup

Add the plugin to your sanity.config.ts:

import {defineConfig} from 'sanity'
import {blockStyles} from 'sanity-plugin-block-styles'

export default defineConfig({
  // ...
  plugins: [blockStyles()],
})

This registers the blockStyles object type globally. No other config needed.

Usage

Add blockStyles as a field on any schema type:

import {defineType, defineField} from 'sanity'

export const mySection = defineType({
  name: 'mySection',
  type: 'object',
  fields: [
    defineField({
      name: 'title',
      type: 'string',
    }),
    defineField({
      name: 'blockStyles',
      type: 'blockStyles',
      options: {collapsible: true, collapsed: true},
    }),
  ],
})

Editors get the full visual style panel. On the frontend, read the blockStyles object and apply as inline styles or CSS classes.

Data shape

The blockStyles field stores this structure:

{
  "padding": {
    "top": "24px",
    "bottom": "48px",
    "topMd": "32px",
    "bottomMd": "64px",
    "topLg": "48px",
    "bottomLg": "80px"
  },
  "margin": { "top": "0", "bottom": "24px" },
  "border": { "width": "1px", "style": "solid", "color": "#e4e4e7" },
  "borderRadius": { "topLeft": "8px", "topRight": "8px", "bottomRight": "8px", "bottomLeft": "8px" },
  "background": { "color": "#fafafa" },
  "typography": { "textAlign": "center", "fontSize": "16", "textColor": "#09090b" },
  "effects": { "shadow": "md", "opacity": 100 }
}

Responsive fields (topMd, topLg, etc.) correspond to tablet (768px) and desktop (1024px) breakpoints.

Frontend example

function applyBlockStyles(styles) {
  if (!styles) return {}

  return {
    paddingTop: styles.padding?.top,
    paddingBottom: styles.padding?.bottom,
    marginTop: styles.margin?.top,
    backgroundColor: styles.background?.color,
    borderWidth: styles.border?.width,
    borderStyle: styles.border?.style,
    borderColor: styles.border?.color,
    borderRadius: styles.borderRadius
      ? `${styles.borderRadius.topLeft || '0'} ${styles.borderRadius.topRight || '0'} ${styles.borderRadius.bottomRight || '0'} ${styles.borderRadius.bottomLeft || '0'}`
      : undefined,
    textAlign: styles.typography?.textAlign,
    color: styles.typography?.textColor,
  }
}

// For responsive overrides, use CSS custom properties:
// Set --pt-md, --pt-lg as inline style values,
// then in your global CSS:
//
// @media (min-width: 768px) {
//   [style*='--pt-md'] { padding-top: var(--pt-md) !important; }
// }
// @media (min-width: 1024px) {
//   [style*='--pt-lg'] { padding-top: var(--pt-lg) !important; }
// }

Using individual components

You can import any input component standalone for use in custom schemas:

import {
  SpacingInput,
  BorderStyleInput,
  BorderRadiusInput,
  BackgroundInput,
  TypographyInput,
  EffectsInput,
  ColorInput,
  ColorStringInput,
} from 'sanity-plugin-block-styles'

ColorStringInput works as a drop-in components.input for any type: 'string' field that represents a color:

import {ColorStringInput} from 'sanity-plugin-block-styles'

defineField({
  name: 'backgroundColor',
  type: 'string',
  components: {input: ColorStringInput},
})

License

MIT © ogi988

Develop & test

This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.

npm run build    # Build the plugin
npm run watch    # Watch mode for development

See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.