Socket
Socket
Sign inDemoInstall

@docusaurus/theme-common

Package Overview
Dependencies
15
Maintainers
4
Versions
1658
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/theme-common

Common code for Docusaurus themes.


Version published
Maintainers
4
Created

Package description

What is @docusaurus/theme-common?

@docusaurus/theme-common is a package that provides common utilities and components for building themes in Docusaurus, a popular static site generator. It includes shared components, hooks, and utilities that can be used to create custom themes or extend existing ones.

What are @docusaurus/theme-common's main functionalities?

useThemeConfig

The `useThemeConfig` hook allows you to access the theme configuration in your components. This is useful for customizing the appearance and behavior of your site based on the theme settings.

import { useThemeConfig } from '@docusaurus/theme-common';

const MyComponent = () => {
  const themeConfig = useThemeConfig();
  return <div>{JSON.stringify(themeConfig)}</div>;
};

useColorMode

The `useColorMode` hook provides access to the current color mode (light or dark) and a function to toggle it. This is useful for implementing dark mode support in your custom themes.

import { useColorMode } from '@docusaurus/theme-common';

const MyComponent = () => {
  const { colorMode, setColorMode } = useColorMode();
  return (
    <div>
      <p>Current color mode: {colorMode}</p>
      <button onClick={() => setColorMode(colorMode === 'dark' ? 'light' : 'dark')}>Toggle Color Mode</button>
    </div>
  );
};

useWindowSize

The `useWindowSize` hook provides the current window size, which can be useful for responsive design and adapting your components based on the viewport dimensions.

import { useWindowSize } from '@docusaurus/theme-common';

const MyComponent = () => {
  const windowSize = useWindowSize();
  return <div>Window size: {windowSize.width} x {windowSize.height}</div>;
};

Other packages similar to @docusaurus/theme-common

Changelog

Source

3.3.2 (2024-05-03)

:bug: Bug Fix
  • docusaurus-module-type-aliases, docusaurus
    • #10103 fix(core): do not recreate ReactDOM Root, fix React warning on hot reload (@slorber)
Committers: 1

Readme

Source

@docusaurus/theme-common

Common code for Docusaurus themes.

FAQs

Last updated on 03 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc