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

datocms-plugin-custom-text-styles

v1.2.0

Published

A DatoCMS plugin that gives you the ability to have custom styles for Structured Text Fields.

Readme

DatoCMS plugin: Custom text Styles

This DatoCMS plugin makes it possible to add custom styles to the editor of Structured text fields by setting css properties. You can add as many styles as you'd like in the Plugin settings. preview of Custom Text Styles plugin

Features

  • Add custom styles to editor of Structured Text Fields
  • add custom marks (inline styles) to editor of Structured Text Fields
  • Add custom CSS class names to rendered nodes in your Structured Text Fields

Configuration

Plugin Settings

Custom Styles

Add your own Custom Styles. You can set the following attributes:

  • Slug Set this slug to what you want your final css class to be. Please Note: Upon changing this property, you will have to update all Structured Text Fields already used in DatoCMS.

  • Title This title will be shown in the DatoCMS Structured Text editor.

  • Node For now, you can choose between heading and paragraph

  • CSS This is the CSS shown in the DatoCMS Structured Text editor Settings for Styles in Custom Text Styles plugin

    Custom Marks

    Add your own Custom Marks (inline styles). You can set the following attributes:

  • Slug Set this slug to what you want your final css class to be. Please Note: Upon changing this property, you will have to update all Structured Text Fields already used in DatoCMS.

  • Title This title will be shown in the DatoCMS Structured Text editor.

  • Icon You can set an icon name based on the icons available from fontawesome free icons

  • Keyboard Shortcut You can set a keyboard shortcut you can use inside the DatoCMS Structured Text editor.

  • CSS This is the CSS shown in the DatoCMS Structured Text editor Settings for marks in Custom Text Styles plugin

Front End Structured Text Implementation

Custom Styles

Nodes inside Structured Text will be rendered with a style attribute corresponding with the Slug set in the Plugin Settings. (See more info from DatoCMS)[https://www.datocms.com/docs/plugin-sdk/structured-text-customizations#adding-custom-styles-to-nodes]

{
    "type": "paragraph",
    "style": "centered",
    "children": [
      {
        "type": "span",
        "value": "This text is centered"
      }
    ]
},

Update your front end so that you attribute the style property as a CSS class.

// example of a possible implementation of a Paragraph Node
---
import type { Paragraph } from 'datocms-structured-text-utils';

interface Props {
  node: Paragraph;
}

const { node } = Astro.props;
---
// Style attribute ('centered') will be accesible from the node
// Paragraphs that have a custom style of 'Centered' will have the css class 'centered'
<p class={node.style}><slot /></p>
<!-- rendered HTML -->
<p class='centered'> This text is centered</p>

You can now proceed to implement your own custom CSS for the centered class

p.centered {
  text-align: center;
}

Custom Marks

Marks inside Structured Text will be rendered with a mark attribute corresponding with the Slug set in the Plugin Settings. (See more info from DatoCMS)[https://www.datocms.com/docs/plugin-sdk/structured-text-customizations#adding-custom-marks]

 {
      "type": "paragraph",
      "children": [
        {
          "type": "span",
          "value": "This is normal text with"
        },
        {
          "type": "span",
          "marks": ["shout"],
          "value": "only this part"
        },
        {
          "type": "span",
          "value": "having a different mark."
        }
      ]
    }

Update your front end so that you attribute the mark property as a CSS class.

// example of a possible implementation of a Mark
---
import type { DefaultMark, Span } from 'datocms-structured-text-utils';

interface Props {
  node: Span;
}

const { node } = Astro.props;

type Tag = 'span' | 'strong' | 'em' | 'del' | 'mark' | 'code' | 'u';

const elementByMark: Record<string | DefaultMark, Tag> = {
  strong: 'strong',
  code: 'code',
  emphasis: 'em',
  underline: 'u',
  strikethrough: 'del',
  highlight: 'mark',

  // Add custom marks set in custom-text-styles plugin. You can set this to any valid html tag.
  'shout': 'strong',
};

// ensure that all html tags are included
// note the usage of 'node.marks' here, this is were all the applied marks are being stored.
// in our case, this will include 'shout'
const Tags: { Tag: Tag; mark: string }[] =
  node.marks?.map((mark) => {
    const Tag = elementByMark[mark] || 'span';
    return { Tag: Tag, mark };
  }) || [];
---

{
  Tags.reduce(
    (children, { Tag, mark }) => <Tag class={mark}>{children}</Tag>,
    node.value
  )
}
<!-- rendered HTML -->
 <!-- notice that the tag with the 'shout' class is the same as set in elementByMark -->
<p>This is normal text with <strong class="shout">only this part</strong> having a different mark.</p>
strong.shout {
  text-transform: uppercase;
}

Contributing

See contributing.md.