mui / mui/base-ui

[positioner] Can I use the `useAnchorPositioning.SharedParameters` type?

Open
#2,534 2 comments 0 reactions 0 assignees View on GitHub
component: popover support: question typescript
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

# Get help

## Ask a question

I'm trying to apply common styles to elements that use the Positioner component. To do this, I need access to the `useAnchorPositioning.SharedParameters` type.

Here's how I'd ideally like to use it:

```ts
import type { useAnchorPositioning } from '@base-ui-components/react';

export type DefaultPositionerProps = useAnchorPositioning.SharedParameters;

export type Side = DefaultPositionerProps['side'];
export type Align = DefaultPositionerProps['align'];

export const defaultPositionerProps: DefaultPositionerProps = {
collisionAvoidance: { align: 'none' },
};
```

This approach would allow me to catch type errors if the type definitions change in the library, which is exactly what I want.

However, the `useAnchorPositioning.SharedParameters` type is not currently exported from the module. My current workaround involves importing it directly from the `node_modules` folder (e.g., `'node_modules/@base-ui-components/react/esm/utils/useAnchorPositioning'`), but this can interfere with tree-shaking and cause other issues.

I was wondering if you have any plans to export the `useAnchorPositioning` function or the `useAnchorPositioning.SharedParameters` type.

Alternatively, I would appreciate it if you could suggest another way to achieve this.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.