Besides the wide range of pre-built DocLayer components, you can also create your own custom ones. And since you're working with Nuxt UI, you can use any of the library's available components within yours. There are two main scenarios for using custom components: within the app itself, to extend and/or build upon, and as a content components.
Creating custom content components
Since it's difficult to anticipate the specific application-level components you may need, we've provided simple tools to help you create globally accessible content components that can be used to extend content presentation or to build reusable content containers.
We plan to build several more components, so if you would like to contribute and build them with us, don't hesitate to send your Pull Request - it will be highly appreciated. 💪
Built-in content components
DocLayer's built-in content components are created using the same techniques described below. As you work with these components, you can refer to the relevant sections of this page to better understand how they function and how you can use them.
While building your own components remember about naming and location restrictions. Try to avoid conflicts and margin issues.
To create a custom content component, simply add it to the app/components/content directory, as the Nuxt Content structure reference. It will then be automatically available for use in your Markdown files. Any application-wise components can be stored outside the content folder.
This is a simple example of your desired structure:
To build a custom content component, you can use the DlWrapper. It's a powerful tool that allows you to define and apply Tailwind classes directly to your component's markup, including resolving them in Markdown files, without needing to modify any CSS files. It can also extend properties directly from your Markdown files, and supports resolving data dynamically.
DlWrapper
The DlWrapper is not a content component and is not intended to be used directly within Markdown files. Instead, it serves as the foundation for building content components.
To help you build performant and extensible content components, we've created a DlWrapper - for us, the main foundation for building content blocks. It serves three primary purposes:
- resolving the component's markup UI,
- lazy-load the component when needed,
- extend / overwrite the component's props.
Think of it as unlocking greater capabilities for content components that can be used inside Markdown. While it does help you develop faster, its main purpose is to provide the best possible experience for content creators.
Note that nearly all pre-built content components utilize this component and inherit all of its features.
Let's explore each feature to learn how to effectively use this unique component inside your DocLayer application.
Styling content components
The DlWrapper component allows you to define and apply Tailwind classes directly to your component’s markup, including resolving them in the Markdown files, without any CSS files modifications. It wraps your custom component, passing a set of classes to specific elements within your markup structure.
This is how the simple implementation looks like:
Let's break down what's happening in this example, step by step.
The DlWrapper component takes a ui prop, which should be resolved using the resolvePropsUi handler - you can get it from the useComponentUi composable. Pass to this handler your component's props. Under the hood it will resolve the final UI configuration for your custom component.
To set component's UI (under the ui prop) use defineDoclayerComponentUi macro function. This macro allows you to define Tailwind classes for each part of your component's markup as an arrays of strings, making it easier to get class name suggestions (thanks to TypeScript) right in your Vue file. These arrays are automatically joined into valid Tailwind class strings becoming available to transfer into your component’s markup. You can also add your own utility classes at any time.
This is how Tailwind classes will be suggested to you by the Typescript compiler - you'll get the list of all default ones.

Make sure to use the UiProps type when defining properties, as Typescript will automatically infer the correct classes values within your component's HTML markup.
Diving a bit deeper
ui property is intended to be internal one, used only to define the component's markup Tailwind classes. You should not pass it manually when using your custom component in Markdown files, as it will be handled automatically by the DlWrapper.
You may wonder as well, why the ui property is defined outside of the script setup block. This is because Vue hoists static declarations to the module scope, making them accessible to the setup function before it is executed, not causing any data reading issues.
Next, DlWrapper provides a special slot that gives you access to the resolved ui object (here referred as $ui, not to collide with the ui property). Internally, the component merges the props.ui configuration defined in your custom component with any overrides passed from the Markdown file. The resulting Tailwind classes are then made available through the slot data, so you can easily apply them in your component’s markup. Even better, the entire ui structure is type-safe and will be auto-suggested in your component's template.

You may notice the special base property inside the container object. This one is automatically and specifically added for defining ui configuration for the Nuxt UI components. You can learn more about it in the section below.
Styling limitations
Some components have more complex markup, additional elements, or behaviors that are difficult to style using only simple Tailwind classes. In these cases, the built-in components use more advanced styling techniques, including pseudo elements or special utility classes that set component-specific CSS variables. These variables are defined near each relevant component and will be documented in their respective pages. This approach still gives you extensive - if not complete - control over the component’s appearance, without needing to create separate custom CSS files.
Styling inside the Markdown files
Now that you've defined your component's UI, it will be styled as you intended and displayed consistently throughout your application. But what if you want to change its appearance in just one specific place? Without needing to use CSS files and create special custom classes to override the predefined ones, you can easily style your component directly from the Markdown file. This is how you can do it.
With the special #ui slot, you can either add to or overwrite the classes assigned to specific markup elements of your component, as previously defined. The example above shows how to add new classes to any component's markup element, while the example below demonstrates how to completely overwrite / replace full class list.
As you can see, to completely replace the classes, you need to use a dedicated callback function.
Styling inside the Markdown files with CSS variables
What's even more interesting you can use CSS variables to style components markup directly from the Markdown file. You can do it like this:
It's important to note that the classes and variables you use must be Tailwind-based. For example, if you're using a bg-* class to set the background color, you need to define a corresponding CSS variable (like --color-bloody) that Tailwind references for that class, as it's strictly connected.
Remember our claim? Everything remains within the Markdown. 😜
Styling inline components
The examples above apply to block components. Inline components use a different syntax, so you can't use named slots with them. To address this, we've introduced a special iui prop, which is passed from the DlWrapper to any of your custom components. With this prop, you can provide a string object containing your custom Tailwind classes and pass them directly to the component.
Yo can do it like this:
Inline components limitations
Please note that inline components don't support overwriting the full class list - you just can't use named slots with them. Although you can enforce your custom classes by:
- using the
!(important) modifier, added withiuiprop, - or defining them as a block component(s) instead, using
uislot.
Working with Nuxt UI components
Since we have Nuxt UI on board, you may want to use its components inside your own custom ones. One of the most important features of Nuxt UI components is that you can adjust their UI in a way similar to DocLayer components. Each Nuxt UI component exposes a ui prop, which lets you provide your own set of classes to customize the component’s style variants.
In many cases, these components have a base property within the ui object. This base property is typically responsible for styling the component’s main container. While not every component follows this pattern, it is quite common. For this reason, when you define a UI element using the defineDoclayerComponentUi macro, we also include a special base property.
This means that when you pass custom styles to Nuxt UI components, you don’t need to define the base property yourself - it will be passed automatically. Additionally, you can use the base value for your own component’s container. Simply use $ui.base wherever you need it, and it will be automatically resolved by the DlWrapper.
Extending content component properties
The DlWrapper component - used as the foundation for any custom content component - can handle dynamic data for any of your block component properties. Thanks to the special usePropsExtender composable, you can overwrite props values by using the dedicated #props slot.
Here’s how you can do it for globally defined data within the dl.inDocData:
And this is how you can do it with locally (per page) defined data:
More about defining local data you can read here.
Why to use built-in property extending?
You might ask why this approach is better than simply passing regular dynamic properties to your content components?
- First, it’s not limited to local data - you can provide data from parent components as well as from the global registry, managed by the
dl.inDocDataobject. - Second, dynamic property binding with the
$dochandler isn’t possible when using regular dynamic props, since those values are resolved as static data, which can make data binding inconsistent. - Third, you can mix static and dynamic content for the same property.
- Finally, with this approach, data binding happens at the component level, is cached, and reused for future renders, rather than being resolved each time during Markdown parsing.
Lazy loading content components
The DlWrapper component supports lazy loading of content components. To enable this, pass the lazy prop to the component. With this setup, your component will be rendered only when it becomes visible - that is, when the user scrolls to the section of the page where the component appears. You can define it like this:
You can also control lazy loading from Markdown files. As shown above, simply use the utilBooleanString function to resolve the boolean value passed as a string.
DlRenderer
Now that you know how to create a new custom content components, let's explore how you can use them along with reusable ones.
When writing content, you may want to avoid repeating the same chunks of information throughout your files, having at the same time more control over reusable sections. Since Nuxt Content doesn't offer a strict solution for this, DocLayer provides you with an easy and extensive way to handle it.
You can do this easily using the dedicated DlRenderer component. For more details on how to use it with your content, check the component's page.
