Skip to content

Typings for custom components #195

Discussion options

You must be logged in to vote
import { Box } from '@suid/material';
import { BoxProps } from '@suid/material/Box/BoxProps';
import { splitProps } from 'solid-js';

const boxProps = ['sx', 'children', 'margin'] as const;

function MyBox(
  inProps: Pick<BoxProps, typeof boxProps[number]> & {
    subchildren?: string;
  }
) {
  const [boxProps, props] = splitProps(inProps, boxProps);
  return (
    <>
      <Box {...boxProps} />
      {props.subchildren}
    </>
  );
}

export default function App() {
  return (
    <MyBox subchildren="test" margin={3} sx={{ color: 'red' }}>
      hello world
    </MyBox>
  );
}

or

import { Box } from '@suid/material';
import { JSXElement } from 'solid-js';

function MyBox(props: {
  ch…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@martinpengellyphillips
Comment options

Answer selected by martinpengellyphillips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants