Code Monkey home page Code Monkey logo

themes's People

Contributors

andy-hook avatar asuka109 avatar benoitgrelard avatar chsir17 avatar f0rr0 avatar jay1803 avatar kendallstrautman avatar lucasmotta avatar penx avatar phuctm97 avatar vladmoroz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

themes's Issues

Avoid dependencies on "latest" version to allow for stable builds

Currently, it's not possible to use radix-ui/themes with an immutable yarn.lock file due to the radix-ui/themes package's dependencies on the latest versions of radix-ui packages. Reproducible builds across various environments are highly desirable, and there's a need to run yarn install --immutable to ensure the yarn.lock file remains unmodified on the server.

How to fix: use dependencies with specific version in "frontend\radix-ui\themes\packages\radix-ui-themes\package.json" instead of latest.

next 13.4.2 - Hydration failure with Theme

When I use <Theme> inside _app.tsx (from import { Theme } from '@radix-ui/themes')

I got this error:

Hydration failed because the initial UI does not match what was rendered on the server.

Removing Theme gets rid of Hydration failure completely.

Error: "ENOENT: no such file or directory"

Hi, guys

I'm trying to install and configure @radix-ui/themes and I get this error message:
image

I followed the steps in the official documentation. Getting started

  1. npm install @radix-ui/themes
  2. import '@radix-ui/themes/styles.css';
  3. And I tried to import and use in my PageLayout component:
import { PageHeader } from '~/templates/PageHeader/PageHeader';
import { PageFooter } from '~/templates/PageFooter/PageFooter';
import { Theme } from '@radix-ui/themes';

export const PageLayout = ({ children }) => {
  return (
    <Theme>
      <PageHeader />
      <main>{children}</main>
      <PageFooter />
    </Theme>
  );
};

Could someone help me with this problem?

Hydration and flashing select component

Hi, i was experimenting with the components and i tried to do a select theme switcher with next-themes but the select value flashes and i have an hydration error.

"use client";
import { Select } from "@radix-ui/themes";
import { useTheme } from "next-themes";

export default function ThemeSwitcher() {
  const { theme, setTheme } = useTheme();

  return (
    <Select.Root
      value={theme}
      onValueChange={(value) => setTheme(value)}
      size="2"
    >
      <Select.Trigger variant="soft" />
      <Select.Content>
        <Select.Item value="dark">Dark</Select.Item>
        <Select.Item value="light">Light</Select.Item>
      </Select.Content>
    </Select.Root>
  );
}

button's classname passed from UI doesn't take precedence(unable to change color)

hi folks! lovely library. I was just wondering if passing the incoming props before inbuilt class names is intentional?

What I'm trying to do -

<Button className="fancy-gradient-button" />

<Button className="disabled-btn" />

But in this the background of the button doesn't take precedence, as the classnames from the library come later. This behaviour in general is common for all components. Am I missing something obvious or is this expected(which also makes sense for consistency)?

[Website] Android Firefox is Broken

On Android Firefox, I can't seem to scroll. Or whole sections of the homepage go black. Generally unusable - maybe the hug of death?

Just the landing page

I'll attach a video when I can (too large for Github)

Getting started questions

Hey there, I'm just getting started with Radix-UI and after reading through the documentation, I have a few questions

  1. Is there a way to lazily render tabs? Sometimes, a tab view is expensive to render or has to make network requests to load, so its nice to be able to render them lazily.
  2. Same question with context menus. In Notion, for example, if you right click on a block, there's a decent amount of computation that goes on in order to figure out what kinds of actions can be taken on that block. So it would be nice to be able to lazily populate context menus as well.
  3. If I just want some text with an icon next to it, what's the best way of doing that? For example, the a tab heading or a badge with an icon.

I hope this is an appropriate place to put this.

Thanks!

Can't import into Astro project

This is my Astro layout:

---
import '@radix-ui/themes/styles.css';
import { Theme } from '@radix-ui/themes';

interface Props {
  title: string;
}

const { title } = Astro.props;
---

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="description" content="Astro description" />
    <meta name="viewport" content="width=device-width" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="generator" content={Astro.generator} />
    <title>{title}</title>
  </head>
  <body>
		<Theme>
			<slot />
		</Theme>
  </body>
</html>

However, I can't import Theme from @radix-ui/themes because of this error:

 error   Unexpected token 'export'
/home/.../node_modules/@radix-ui/themes/dist/esm/index.js:1
export { Theme, useThemeContext, updateThemeAppearanceClass } from './theme';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1176:20)
    at Module._compile (node:internal/modules/cjs/loader:1218:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) (x2)

Any help would be appreciated.

Theme swaps between light and dark infinitively

Issue

After entering for the first time in the Playgound and switching the theme to dark, I unlock the disco mode.

032ed23cdfc4fcdfccb22cadf4b82c6d.mp4

Steps to reproduce it

  • Open Chrome/Firefox/Brave and open incognito
  • Go to the Playground
  • Click Dark

[ThemePanel - Bug] Appearance switch of ThemePanel doesn't work properly

I tried the ThemePanel at play ground and wanted to add it to my React application.

I use <Theme appearance="dark" accentColor="tomato" grayColor="sage">, so I set the appearance to dark as default. When I start the app, the Light radio input is selected, while the Panel is in dark theme. After clicking on Light radio input, it turns to Light theme but the dark theme radio input can't be selected.

I guess it is because of class of the ThemePanel can't find a way to change from light to dark

Translate theme panel hotkeys to Windows and Linux

When the theme panel, e.g. in playground is opened from a non-Apple device (Windows, Linux), the โŒ˜C and โŒ˜D hotkeys to toggle the theme panel and dark mode should be automatically remapped to Ctrl-C and Ctrl-D respectively.
As of now they are mapped strictly for Apple devices and don't work elsewhere.

This requires modifying these handleKeydown functions to include ctrlKey:

// quickly show/hide using โŒ˜C
React.useEffect(() => {
function handleKeydown(event: KeyboardEvent) {
const isCmdC =
event.metaKey && event.key === 'c' && !event.shiftKey && !event.altKey && !event.ctrlKey;
if (isCmdC && window.getSelection()?.toString() === '') {
onOpenChange(!open);
}
}
document.addEventListener('keydown', handleKeydown);
return () => document.removeEventListener('keydown', handleKeydown);
}, [onOpenChange, open]);
// quickly toggle appearance using cmd+d
React.useEffect(() => {
function handleKeydown(event: KeyboardEvent) {
if (event.metaKey && event.key === 'd') {
event.preventDefault();
handleAppearanceChange(appearance === 'dark' ? 'light' : 'dark');
}
}
document.addEventListener('keydown', handleKeydown);
return () => document.removeEventListener('keydown', handleKeydown);
}, [appearance, handleAppearanceChange]);

and automatically showing the correct key (โŒ˜ or ctrl) here:

<Kbd size="3" tabIndex={0} className="rt-ThemePanelShortcut">
โŒ˜&thinsp;C
</Kbd>

This can be a good example.

Fixing this issue will make the theme panel work the same for everyone, regardless of the OS used.

Cannot import styles.css

Trying to import styles.css via @import url(@radix-ui/themes/styles.css); in a CSS file results in the following error:

ERROR in ./src/app/index.css (./node_modules/css-loader/dist/cjs.js!./src/app/index.css)

Module build failed (from ./node_modules/css-loader/dist/cjs.js):
Error: Package path ./styles.css is not exported from package [...]\node_modules\@radix-ui\themes
(see exports field in [...]\node_modules\@radix-ui\themes\package.json)

However, when I go check the exports field in the package's package.json, I can clearly see the ./styles.css being exported.

Similarly, importing styles.css in a TypeScript (or a JavaScript) file via import '@radix-ui/themes/styles.css' results in a no-op. It simply does not inject the CSS into the generated chunks and has no effect whatsoever on the HTML output. Importing any other CSS file works as expected.

I am using Webpack 5.88.2.
Any idea what's going on? Could this be a bug in Webpack?

Dark theme stops being applied when children contain client-rendered context (NextJS 13)

Hi!

I was so excited by the release of the themes package that I thought I'd rewrite a small internal app in Next 13 with it and have some fun.

Here's the rub - this works:

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className={inter.className}>
        <Theme appearance="dark" accentColor="red">
          <p>This will render dark</p>
        </Theme>
      </body>
    </html>
  )
}

This doesn't work (renders light theme):

'use client'

import React from 'react'

const TestContext = React.createContext(null)

export const ClientOnly = () => (
  <TestContext.Provider value={null}>
    <p>This is client only and renders light</p>
  </TestContext.Provider>
)

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className={inter.className}>
        <Theme appearance="dark" accentColor="red">
          <ClientOnly />
        </Theme>
      </body>
    </html>
  )
}

Seems like a bug right?

Svelte support

I know next to nothing about radix-ui, but the new UI library looks very nice! I was wondering if Svelte support will be added since I prefer to use it over React.

[Proposal]: Variable Breakpoints

What are people's thoughts around making breakpoint variables?

If amenable, I think the solution would be fairly straight forward. The breakpoints.css file could be updated to something like:

.radix-themes {
  --breakpoint-xs: 520px;
  --breakpoint-sm: 768px;
  --breakpoint-md: 1024px;
  --breakpoint-lg: 1280px;
  --breakpoint-xl: 1640px;
}

@custom-media --xs (min-width: var(--breakpoint-xs));
@custom-media --sm (min-width: var(--breakpoint-sm));
@custom-media --md (min-width: var(--breakpoint-md));
@custom-media --lg (min-width: var(--breakpoint-lg));
@custom-media --xl (min-width: var(--breakpoint-xl));

Long term, my hope is that Container could move from the following sizes:

.radix-themes {
  --container-1: 448px;
  --container-2: 688px;
  --container-3: 880px;
  --container-4: 1136px;
}

To something like:

.radix-themes {
  --container-xs: var(--breakpoint-xs);
  --container-sm: var(--breakpoint-sm);
  --container-md: var(--breakpoint-md);
  --container-lg: var(--breakpoint-lg);
  --container-xl: var(--breakpoint-xl);
}

TextField.Input styling

I'm trying to style the TextField.Input and it's a bit impossible to do right now because there is an extra <div class="rt-TextFieldChrome"> rendered in markup that contains real styling, and the className from Input component is not applied to it.
Not really sure why this div exists, but it would be nice to be able to customize the component by adding classes to Input's className.

[Request] Add variable accent to color enum

If a parent component has a color set, it is inherited by the children. This is useful in most cases, but I've found a few times I wanted to reset the component's color back to the theme accent. The way I've been accomplishing this is to override the color again on the child, but then it doesn't change with the theme accent

It would be nice to have a way to set a components color to match the theme color no matter what.

With no color specified on the link, it will be gray, inherited from parent callout

<Callout.Root color="gray">
    <Callout.Icon>
      <InfoCircledIcon />
    </Callout.Icon>
    <Callout.Text>
      You will need <Link href="#">admin privileges</Link> to install and access
      this application.
    </Callout.Text>
  </Callout.Root>

We can override the link's color to violet, but it won't change with the theme

<Callout.Root color="gray">
    <Callout.Icon>
      <InfoCircledIcon />
    </Callout.Icon>
    <Callout.Text>
      You will need <Link color="violet" href="#">admin privileges</Link> to install and access
      this application.
    </Callout.Text>
  </Callout.Root>

Proposed idea to be able to 'reset' the link's color back to the theme accent

<Callout.Root color="gray">
    <Callout.Icon>
      <InfoCircledIcon />
    </Callout.Icon>
    <Callout.Text>
      You will need <Link color="accent" href="#">admin privileges</Link> to install and access
      this application.
    </Callout.Text>
  </Callout.Root>

[Dialog] Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>

Warning: validateDOMNesting(...):

cannot appear as a descendant of

.
at div
at p
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-primitive/dist/index.mjs:44:26)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:316:28)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-alert-dialog/dist/index.mjs:153:33)
at _c8 (webpack-internal:///(app-pages-browser)/./components/ui/alert-dialog.tsx:139:11)
at div
at $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-slot/dist/index.mjs:56:165)
at div
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-primitive/dist/index.mjs:44:26)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs:44:42)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-slot/dist/index.mjs:46:23)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-slot/dist/index.mjs:20:23)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-primitive/dist/index.mjs:44:26)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-focus-scope/dist/index.mjs:32:19)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:274:28)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:206:102)
at $921a889cee6df7e8$export$99c2b779aa4e8b8b (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-presence/dist/index.mjs:28:22)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:191:108)
at Provider (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-context/dist/index.mjs:47:28)
at Provider (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-context/dist/index.mjs:13:27)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-alert-dialog/dist/index.mjs:105:33)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-slot/dist/index.mjs:46:23)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-slot/dist/index.mjs:20:23)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-primitive/dist/index.mjs:44:26)
at eval (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-portal/dist/index.mjs:24:24)
at $921a889cee6df7e8$export$99c2b779aa4e8b8b (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-presence/dist/index.mjs:28:22)
at Provider (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-context/dist/index.mjs:47:28)
at $5d3850c4d0b4e6c7$export$dad7c95542bacce0 (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:133:28)
at $905f4ae918aab1aa$export$660f2bfdb986706c (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-alert-dialog/dist/index.mjs:80:33)
at AlertDialogPortal (webpack-internal:///(app-pages-browser)/./components/ui/alert-dialog.tsx:28:11)
at eval (webpack-internal:///(app-pages-browser)/./components/ui/alert-dialog.tsx:55:11)
at Provider (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-context/dist/index.mjs:47:28)
at $5d3850c4d0b4e6c7$export$3ddf2d174ce01153 (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-dialog/dist/index.mjs:77:28)
at $905f4ae918aab1aa$export$de466dd8317b0b75 (webpack-internal:///(app-pages-browser)/./node_modules/@radix-ui/react-alert-dialog/dist/index.mjs:54:33)
at form
at FormProvider (webpack-internal:///(app-pages-browser)/./node_modules/react-hook-form/dist/index.esm.mjs:180:13)
at UploadForm (webpack-internal:///(app-pages-browser)/./components/interview/UploadForm.tsx:107:88)
at div
at div
at div
at div
at main
at InnerLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:240:11)
at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)
at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)
at NotFoundErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:54:9)
at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:62:11)
at LoadingBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:337:11)
at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:110:11)
at InnerScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:151:9)
at ScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:226:11)
at RenderFromTemplateContext (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/render-from-template-context.js:15:44)
at OuterLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:347:11)
at div
at div
at f (webpack-internal:///(app-pages-browser)/./node_modules/next-themes/dist/index.module.js:8:597)
at $ (webpack-internal:///(app-pages-browser)/./node_modules/next-themes/dist/index.module.js:8:348)
at ThemeProvider (webpack-internal:///(app-pages-browser)/./components/theme-provider.tsx:13:11)
at QueryClientProvider (webpack-internal:///(app-pages-browser)/./node_modules/react-query/es/react/QueryClientProvider.js:39:21)
at body
at html
at RootLayout (webpack-internal:///(app-pages-browser)/./app/layout.tsx:23:11)
at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)
at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)
at NotFoundErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:54:9)
at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:62:11)
at DevRootNotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/dev-root-not-found-boundary.js:32:11)
at ReactDevOverlay (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/react-dev-overlay/internal/ReactDevOverlay.js:66:9)
at HotReload (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/react-dev-overlay/hot-reloader-client.js:326:11)
at Router (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/app-router.js:147:11)
at ErrorBoundaryHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:82:9)
at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:110:11)
at AppRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/app-router.js:417:13)
at ServerRoot (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js:123:11)
at RSCComponent
at Root (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js:139:11)

Hover Card Disappears Upon Clicking the Trigger Element

Description:

I am working with a hover card component that is displayed when hovering over the trigger element. However, when I click the trigger element while the cursor is still hovering over it, the hover card disappears, which is not the desired behavior. I want the hover card to remain visible even after clicking the trigger.

Here's the code snippet:

<Flex gap="1" align="center">
  <HoverCard.Root>
    <HoverCard.Trigger>
      <Flex
        gap="1"
        align="center"
        onClick={preventClickEvent}
      >
        <CubeIcon width="12" height="12" color="gray" />
        <RText
          color="gray"
          size="1"
          className="md:block hidden"
          style={{ cursor: "pointer" }}
        >
          file list
        </RText>
      </Flex>
    </HoverCard.Trigger>
    <HoverCard.Content>
      {/* content */}
    </HoverCard.Content>
  </HoverCard.Root>
  {/* other components */}
</Flex>

const preventClickEvent = (event: any) => {
  console.log("preventClickEvent");
  event.preventDefault();
  event.stopPropagation();
};

I tried to prevent the hover card from disappearing by adding a click event prevention function to the trigger element, but it had no effect.

Does anyone have a solution to keep the hover card visible after clicking the trigger element? Any assistance would be greatly appreciated.

The dark theme has not worked properly.

It seems that the issue arises after setting appearance="dark" without properly setting the HTML attributes class="light-theme" and style="color-scheme: light;".

image

RTL support

First of all thanks for this amazing library, I can't stop using it its so good!
I was just wondering if there's any plan to support RTL.
I tried the DirectionProvider and it doesn't work.

'use client'

import { DirectionProvider } from '@radix-ui/react-direction'

type Props = {
  children: React.ReactNode
}

const Direction = (props: Props) => {
  return <DirectionProvider dir='rtl'>{props.children}</DirectionProvider>
}

export default Direction

Thanks!

[DropdownMenu] Implementing a Multilevel Dropdown with TextField.Input as Trigger Component

I'm attempting to create a dropdown component that not only behaves like a combobox but also supports multilevel dropdown menus. My current approach involves changing the trigger inside the DropDown component from a Button to TextField.Input. However, this is not working as expected, since Input cannot be focused like a Button and only allows for a click-like interaction.

I'd like the dropdown to behave like a typical dropdown, but the trigger component should be an input field, allowing for text entry, and then a click on this input field should open the dropdown with multilevel menu items.

I'm not sure how to proceed in order to make this work. Has anyone encountered a similar issue or can provide a solution to this problem?

      <DropdownMenu.Root>
        <DropdownMenu.Trigger>
          <TextField.Root style={{ border: "0px solid red" }}>
            <TextField.Slot
              style={{
                display: "flex",
                flexDirection: "row",
                justifyContent: "flex-end",
                alignItems: "center",
                border: "0px solid red",
              }}
            >
              <MagnifyingGlassIcon height="16" width="16" />
              {/* {!isFocused && inputRef.current?.value === "" && (
                <div className={cssStyle.fakeCursor}></div>
              )} */}
            </TextField.Slot>
            <TextField.Input
              style={{ border: "0px solid blue" }}
              placeholder="Search the docsโ€ฆ"
            />
          </TextField.Root>
        </DropdownMenu.Trigger>
        <DropdownMenu.Content>
          <DropdownMenu.Item shortcut="โŒ˜ E">Edit</DropdownMenu.Item>
          <DropdownMenu.Item shortcut="โŒ˜ D">Duplicate</DropdownMenu.Item>
          <DropdownMenu.Separator />
          <DropdownMenu.Item shortcut="โŒ˜ N">Archive</DropdownMenu.Item>

          <DropdownMenu.Sub>
            <DropdownMenu.SubTrigger>More</DropdownMenu.SubTrigger>
            <DropdownMenu.SubContent>
              <DropdownMenu.Item>Move to projectโ€ฆ</DropdownMenu.Item>
              <DropdownMenu.Item>Move to folderโ€ฆ</DropdownMenu.Item>

              <DropdownMenu.Separator />
              <DropdownMenu.Item>Advanced optionsโ€ฆ</DropdownMenu.Item>
            </DropdownMenu.SubContent>
          </DropdownMenu.Sub>

          <DropdownMenu.Separator />
          <DropdownMenu.Item>Share</DropdownMenu.Item>
          <DropdownMenu.Item>Add to favorites</DropdownMenu.Item>
          <DropdownMenu.Separator />
          <DropdownMenu.Item shortcut="โŒ˜ โŒซ" color="red">
            Delete
          </DropdownMenu.Item>
        </DropdownMenu.Content>
      </DropdownMenu.Root>

Any assistance or pointers on how to make this implementation work would be greatly appreciated. Thank you!

Link as button and vice versa

๐Ÿ‘‹ Enjoying the lib, but one thing I haven't been able to easily figure out is how to treat Link as a button, and Button as a link. For example, want to do these while preserving the original styles:

<Button href="...">View</Button>
<Link onClick={doSomething}>View</Link>

[Card] Issue

There is no card component on radix-ui themes. The card <Card> causes the react app "Cannot find module 'card' on @radix-ui/themes"

Is `@radix-ui/themes` currently working in plain React (without Next.js)?

Hi, I am trying to install Radix in a plain React.js project and getting the following warnings when trying to import @radix-ui/themes:

import { Theme } from "@radix-ui/themes";

Warnings:

WARNING in ../../node_modules/@radix-ui/themes/dist/esm/theme-options.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme-options.tsx' file: Error: ENOENT: no such file or directory, open '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme-options.tsx'

WARNING in ../../node_modules/@radix-ui/themes/dist/esm/theme-panel.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme-panel.tsx' file: Error: ENOENT: no such file or directory, open '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme-panel.tsx'

WARNING in ../../node_modules/@radix-ui/themes/dist/esm/theme.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme.tsx' file: Error: ENOENT: no such file or directory, open '/Users/arielweinberger/Development/pezzo/pezzo/node_modules/@radix-ui/themes/src/theme.tsx'

I see a few other people facing the same issue:

I see no response about this from the maintainers. Are you able to provide an update about this? Would love to adopt Radix in some of my projects.

I seem to be able to import some components such as DropdownMenu like so:

import * as DropdownMenu from "@radix-ui/react-dropdown-menu";

But cannot import Theme.

Steps to reproduce

  1. Create a new React app with create-react-app
  2. Install Radix UI
  3. Try to import and use <Theme>

Wrong Letter Spacing (?)

The default letter spacing is:

  --letter-spacing-1: 0.0025em;
  --letter-spacing-2: 0em;
  --letter-spacing-3: 0em;
  --letter-spacing-4: -0.0025em;
  --letter-spacing-5: -0.005em;
  --letter-spacing-6: -0.00625em;
  --letter-spacing-7: -0.0075em;
  --letter-spacing-8: -0.01em;
  --letter-spacing-9: -0.025em;

Isn't that backwards?

Components like Avatar and Heading scale letter spacing with their size. So as the component grows in size, the text becomes closer together.

Could well be intentional, just thought I would check.

Also: Not sure why 2 & 3 share the same value. It seems like the implementation of, for example, Avatar is leaking into the letter spacing constants. Whereas, I think it would be better if Avatar did:

    }
    &.rt-r-size-2 {
      ...
      letter-spacing: var(--letter-spacing-3);
    }
    &.rt-r-size-3 {
      ...
      letter-spacing: var(--letter-spacing-3);
    }
    &

Instead of:

&.rt-r-size-2 {
--avatar-size: var(--space-6);
border-radius: max(var(--radius-2), var(--radius-full));
--avatar-font-size-one-letter: var(--font-size-3);
--avatar-font-size-two-letters: var(--font-size-2);
letter-spacing: var(--letter-spacing-2);
}
&.rt-r-size-3 {
--avatar-size: var(--space-7);
border-radius: max(var(--radius-3), var(--radius-full));
--avatar-font-size-one-letter: var(--font-size-4);
--avatar-font-size-two-letters: var(--font-size-3);
letter-spacing: var(--letter-spacing-3);

Also, if Heading is supposed to get closer as it grows in size, could simply do something like:

      letter-spacing: calc(-var(--letter-spacing-9) - var(--heading-letter-spacing));

As always, just trying to understand

`asChild` prop not available on `<Table>` components.

asChild prop doesn't exist when on the <Table> components, can't seem to find any reference to asChild in the table.d.ts file. Docs mention that it should be available on multiple table components.

Using the latest version of @radix-ui/themes.

Screen Shot 2023-09-04 at 15 15 53

good first issue

Hi.
Is there any good first issue or starting point for this project ?

Thank you.

[Remix] Named export 'Theme' not found

Trying to use it with Remix but got the error:

import { Theme } from "@radix-ui/themes";

SyntaxError: Named export 'Theme' not found. The requested module '@radix-ui/themes' is a CommonJS module, which may not support all module.exports as named exports.

Request: Responsive orientation for tabs

It would be great if we could set

<Tabs.Root defaultValue="account" orientation = {{ initial: "vertical", md: "horizontal" }} >...

so that tabs look nice on both desktop and mobile.

How can i get primary or secondary color?

When you want to access the colors there is no way to select the primary or secondary color, like this:
<Heading color="text-primary-content background-neutral-200"> Trabajo final de estructuras de datos y algoritmos </Heading>
It would be good if they take Daisyui as a reference for the topic of primary, secondary, neutral colors, etc.

[Feature Request] Fluid `Button`, `TextArea` and `TextField`

Hi,

I've been using radix-ui for what I'm building and really enjoying it! One issue I ran into is often times I want to have a full width button/input (particularly on mobile). I'd like to be able to do something like

<Button fluid={{initial: true, md: false}}>...</Button>

I can work around this by attaching a css class that sets the width or wrapping the Button in a Flex component but that feels needlessly awkward.

Happy to take a crack at implementing this.

Unable to use it with remix-run

I have just installed remix-run with express server..Now I am trying to install radix-ui/themes but it is showing the following error

file:///Users/xxx/remix-express-radix-themes/build/index.js:134
import { Theme } from "@radix-ui/themes";
         ^^^^^
SyntaxError: Named export 'Theme' not found. The requested module '@radix-ui/themes' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@radix-ui/themes';
const { Theme } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at file:///Users/xxx/remix-express-radix-themes/server.js:18:13

Here is the reproduction for the error - https://github.com/iamzee/remix-express-radix-themes
Just clone the repository and start the dev server

node -v 16.20.0

Ignores some Tailwind classes while accepting others

Namely, I wanted to use hover:bg-gray-200 (or any other bg color) class from Tailwind on the Card component to highlight the card mouse hovers over among many other cards, and it absolutely ignores it.

hover:cursor-pointer works just fine. I had to resort to force-injecting style via CSS file, and even then it only worked once I used !important tag:

.card-hover:hover {
background-image: #cacaca !important;
}

It still didn't work without the !important flag.

[TextField] Issue: React.jsx: type is invalid -- expected a string

Hi guys,
I got a problem with TextField

Here is a screenshot of what I got when entered code from template to my component

image

More detailed info is on this screenshot of browser
21-02-35-13-chrome

To fix this on my side I've tried to pass type to TextField.Input but it didn't help me

next13 app directory hydration error

I get a hydration error when I try to use the tag. I haven't found a good solution for this so far.

layout.tsx

import "./globals.css";
import "@radix-ui/themes/styles.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Theme } from "@radix-ui/themes";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <Theme>
        <body className={inter.className}>{children}</body>
      </Theme>
    </html>
  );
}

And I tried something. Create a radix-provider.tsx file and moved <Theme> in this file.

radix-provider.tsx

"use client";

import { useState, useEffect } from "react";
import { Theme } from "@radix-ui/themes";

export default function RadixProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  const [mounted, setMounted] = useState(false);

  useEffect(() => {
    setMounted(true);
  }, []);

  if (!mounted) {
    return null;
  }

  return <Theme>{children}</Theme>;
}

And when i did this, convert layout.tsx file with:

import "./globals.css";
import "@radix-ui/themes/styles.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import RadixProvider from "./radix-provider";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <RadixProvider>
        <body className={inter.className}>{children}</body>
      </RadixProvider>
    </html>
  );
}

But it's didn't worked. Still getting Hydration error.

image

`TextField.Input` loses focus everytime `useState` refresh the state of the component

TextField.Input is losing focus everytime useState set is triggered onChange. This behavior doesn't happend in vanilla inputs using React. Is there any config I am missing or is this a bug?

const [projectBody, setProjectBody] = useState<ProjectForm>({
    name: "",
    description: "",
    category: "",
    budget: "",
  });

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
    const { name, value } = e.target;

    setProjectBody({ ...projectBody, [name]: value });
 };

<form action="" method="POST" className="flex flex-col gap-4">
      <label htmlFor="name">Name *</label>
        <TextField.Input
          size="3"
          name="name"
          id="name"
          placeholder="Cool App..."
          onChange={handleInputChange}
        />
</form>

Project deps:

  • Next: 13.4.19
  • @radix-ui/themes: 1.1.2
  • million: 2.6.0-beta.11

Extract code for organising

<Tabs
   <Tabs.Trigger

Let's say I want to create a component that gives back <Tabs.Trigger... can I do that? How?

<Tabs
   <AcomponentthatReturnsTabTrigger 

I was trying something similar and I got an error saying unsuitable for render

ERROR(TypeScript) from radix-ui

I'm using radix-theme in a vite project. Got this type error from the lib itself :

ERROR(TypeScript) Interface 'ScrollAreaScrollbarImplProps' cannot simultaneously extend types 'Pick<Omit<DetailedHTMLProps<HTMLAttributes, HTMLDivElement>, "ref"> & { ref?: ((instance: HTMLDivElement | null) => void) | ... 2 more ... | undefined; } & { ...; }, "key" | ... 1 more ... | "asChild">' and 'ScrollAreaScrollbarImplPrivateProps'.
Named property 'onResize' of types 'Pick<Omit<DetailedHTMLProps<HTMLAttributes, HTMLDivElement>, "ref"> & { ref?: ((instance: HTMLDivElement | null) => void) | ... 2 more ... | undefined; } & { ...; }, "key" | ... 1 more ... | "asChild">' and 'ScrollAreaScrollbarImplPrivateProps' are not identical.
FILE /Users//node_modules/.pnpm/@radix-ui+react-scroll-area@1.0.4_@types+react-dom@18.2.7_@types[email protected][email protected][email protected]/node_modules/@radix-ui/react-scroll-area/dist/index.d.ts:96:11

  94 |     onResize(): void;
  95 | };
> 96 | interface ScrollAreaScrollbarImplProps extends PrimitiveDivProps, ScrollAreaScrollbarImplPrivateProps {
     |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  97 | }
  98 | type ScrollAreaThumbElement = ScrollAreaThumbImplElement;
  99 | export interface ScrollAreaThumbProps extends ScrollAreaThumbImplProps {

[TypeScript] Found 1 error. Watching for file changes.

Question: Are you planning to introduce loading indicators and lists?

Hello,

Thank you for this library! I really like it and I'm planning to use it on production.

I was wondering if you are planning to include loading indicator components such as spinners, bars and skeletons. On the other hand, the only way to create some sort of list currently is through the Table component, I was also wondering if you are going to incorporate list components (ul and ol)

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.