diff --git a/.changeset/rare-onions-rest.md b/.changeset/rare-onions-rest.md new file mode 100644 index 0000000000..f381b8f163 --- /dev/null +++ b/.changeset/rare-onions-rest.md @@ -0,0 +1,17 @@ +--- +"@clerk/astro": patch +--- + +Allow child elements in unstyled Astro components. + +Usage: + +```astro +--- +import { SignInButton } from '@clerk/components/astro' +--- + + + + +``` diff --git a/integration/templates/astro-node/src/pages/buttons.astro b/integration/templates/astro-node/src/pages/buttons.astro index a559cce8fc..53b21ce962 100644 --- a/integration/templates/astro-node/src/pages/buttons.astro +++ b/integration/templates/astro-node/src/pages/buttons.astro @@ -6,10 +6,13 @@ import Layout from "../layouts/Layout.astro"; - Sign in + = Polymorphic +import type { SignInProps } from '@clerk/types' +import type { ButtonProps } from '../../types'; +import { addUnstyledAttributeToFirstTag, logAsPropUsageDeprecation } from './utils' + +type Props = Polymorphic> import { generateSafeId } from '@clerk/astro/internal'; const safeId = generateSafeId(); +if ('as' in Astro.props) { + logAsPropUsageDeprecation() +} + const { as: Tag = 'button', + asChild, forceRedirectUrl, fallbackRedirectUrl, signUpFallbackRedirectUrl, @@ -23,11 +31,24 @@ const signInOptions = { signUpFallbackRedirectUrl, signUpForceRedirectUrl, }; + +let htmlElement = '' + +if (asChild) { + htmlElement = await Astro.slots.render('default') + htmlElement = addUnstyledAttributeToFirstTag(htmlElement, safeId) +} --- - - Sign in - +{ + asChild ? ( + + ) : ( + + Sign in + + ) +}