Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
The rc-align package is a React component that provides functionality for aligning elements relative to other elements. It is useful for creating tooltips, dropdowns, and other UI components that need to be positioned dynamically based on the position of other elements.
Basic Alignment
This feature allows you to align an element relative to a target element. In this example, the aligned element is positioned such that its top-left corner is aligned with the bottom-left corner of the target element.
import Align from 'rc-align';
const Example = () => (
<Align
target={() => document.getElementById('target-element')}
align={{ points: ['tl', 'bl'] }}
>
<div>Aligned Element</div>
</Align>
);
Dynamic Alignment
This feature allows for dynamic alignment that adjusts when the window is resized. The aligned element is positioned with an additional offset of 10 pixels below the target element.
import Align from 'rc-align';
const Example = () => (
<Align
target={() => document.getElementById('target-element')}
align={{ points: ['tl', 'bl'], offset: [0, 10] }}
monitorWindowResize
>
<div>Aligned Element</div>
</Align>
);
Custom Target
This feature allows you to specify a custom target for alignment. Instead of aligning to an existing DOM element, you can provide custom coordinates and dimensions.
import Align from 'rc-align';
const Example = () => (
<Align
target={() => ({ left: 100, top: 200, width: 50, height: 50 })}
align={{ points: ['tl', 'bl'] }}
>
<div>Aligned Element</div>
</Align>
);
react-popper is a React wrapper around the Popper.js library, which provides powerful positioning and alignment capabilities. It is more feature-rich compared to rc-align, offering advanced positioning options, modifiers, and better handling of edge cases.
react-overlays is a set of utilities for creating overlays in React, including positioning and alignment. It is similar to rc-align but provides additional components and utilities for managing overlays, making it a more comprehensive solution for complex UI components.
react-bootstrap is a popular UI library for React that includes components for positioning and alignment, such as tooltips and popovers. While it offers similar alignment functionalities, it is part of a larger set of UI components, making it a more integrated solution for building complete UIs.
React Align Component. Wrapper around https://github.com/yiminghe/dom-align.
npm install
npm start
http://localhost:8100/examples/
online example: http://react-component.github.io/align/examples/
var Align = require('rc-align');
var ReactDOM = require('react-dom');
ReactDOM.render(<Align align={{}} target={function(){}}><div></div></Align>, container);
will align child with target when mounted or align is changed
name | type | default | description |
---|---|---|---|
align | Object | same with alignConfig from https://github.com/yiminghe/dom-align | |
onAlign | function(source:HTMLElement, align:Object) | called when align | |
target | function():HTMLElement || { pageX: number, pageY: number } || { clientX: number, clientY: number } | function(){return window;} | a function which returned value or point is used for target from https://github.com/yiminghe/dom-align |
monitorWindowResize | Boolean | false | whether realign when window is resized |
rc-align is released under the MIT license.
FAQs
align ui component for react
The npm package rc-align receives a total of 610,614 weekly downloads. As such, rc-align popularity was classified as popular.
We found that rc-align demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.